How to List Tables in PostgreSQL

Last updated July 24, 2026 · By the SaturnSQL team

In psql, \dt lists tables in the search path. From SQL, query pg_tables or information_schema.tables; pg_total_relation_size adds on-disk sizes.

psql

\dt is a psql meta-command rather than SQL, so it only works in psql and fails in any other client. It lists tables in the current search_path; add a schema pattern such as archive.* to look elsewhere, or \dt *.* for everything. \dt+ adds size and description columns.

\dt
\dt archive.*

Plain SQL (works from any client)

pg_tables works from any client, including GUI tools and application code. The quote_ident call matters: without it, a table name that is mixed case or contains a special character breaks the size lookup. Change schemaname to target a different schema, or drop the filter and add it to the SELECT to cover the whole database.

SELECT tablename,
       pg_size_pretty(pg_total_relation_size(quote_ident(tablename))) AS size
FROM pg_tables
WHERE schemaname = 'public'
ORDER BY pg_total_relation_size(quote_ident(tablename)) DESC;

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

Related PostgreSQL guides