How to Show a Table Schema in PostgreSQL
Last updated July 25, 2026 · By the SaturnSQL team
In psql, \d tablename shows columns, types, indexes, and constraints (\d+ adds storage details). From SQL, query information_schema.columns, which works from any client.
psql
\d is the fastest way to understand a table: columns with types and nullability, then indexes, check constraints, foreign keys, and any triggers. \d+ adds storage type, compression, and column comments. Qualify the name as \d archive.orders when the table is not in your search_path.
\d orders
\d+ ordersPlain SQL (works from any client)
information_schema.columns is standard SQL and works from any client, which makes it the right choice inside application code or a saved query. It covers columns only, not indexes or constraints, and reports character_maximum_length and numeric_precision as separate columns rather than as a formatted type string. Ordering by ordinal_position gives you the table's real column order.
SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'orders'
ORDER BY ordinal_position;Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free