Shows every user-visible table in the current database using psql or system catalogs.
Run \dt
inside psql to display every table in the current schema. The command relies on pg_catalog.pg_class
and filters out system objects by default.
Prefix the meta-command with a wildcard: \dt *.*
. The pattern before the dot is the schema filter; the one after is the table filter. Use *
to match everything.
Yes. Query information_schema.tables
or pg_catalog.pg_tables
when you need code that works outside psql.
SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname NOT IN ('pg_catalog','information_schema') ORDER BY schemaname, tablename;
Use \dt schema_name.*
or add WHERE schemaname = 'schema_name'
to the SQL query.
See the next section for a full syntax reference covering psql and SQL approaches.
1️⃣ Use \x
(expanded mode) for wide output. 2️⃣ Combine \dt+ *
with \pset format asciidoc
for copy-pasting. 3️⃣ Prefer information_schema
in portable scripts.
Wrong database: Forgetting to \c database_name
first shows an empty list. Connect to the intended database before running \dt
.
Hidden system tables: Using SELECT * FROM pg_tables
without a WHERE clause returns system tables, causing confusion. Filter out pg_catalog
and information_schema
.
No. \dt is a psql client shortcut. Use SQL queries against information_schema or pg_catalog if you need programmatic access.
Run \dm for materialized views or query pg_matviews.
Yes. Append ORDER BY schemaname, tablename in SQL or pipe psql output through UNIX sort.