Shows all schemas, tables, and columns using psql meta-commands or catalog views.
Need to inspect a database structure fast? PostgreSQL offers psql meta-commands and catalog queries to list schemas, tables, and columns with precision.
In psql
, run \dn
to list every non-system schema. Add \dn+
for owner, ACL, and description details.
Use \dt schema_name.*
to display tables for the chosen schema.Swap \dt
with \dm
, \ds
, or \dv
for other object types.
Query information_schema.tables
or pg_catalog.pg_namespace
when scripting or using a GUI that lacks meta-commands.
SELECT nspname AS schema
FROM pg_catalog.pg_namespace
WHERE nspname NOT LIKE 'pg_%'
AND nspname <> 'information_schema'
ORDER BY 1;
Run \d schema_name.table_name
in psql
or query information_schema.columns
filtering by table_schema
and table_name
.
Filter system schemas, script frequent catalog queries, and combine meta-commands with SQL for automation.
Missing the dot: Typing \dt schema_name*
fails.Always add .*
after the schema.
Lacking privileges: Without the USAGE
right on a schema, its objects stay hidden. Request grants or switch roles.
Editors like Galaxy, TablePlus, or pgAdmin visualize schemas instantly, reducing manual catalog queries.
.
Query pg_namespace
and exclude names starting with pg_
and information_schema
.
Add a plus sign: \dn+
. The description
column shows comments added with COMMENT ON SCHEMA
.
Run \dt *.*
in psql
or query information_schema.tables
without filtering table_schema
.