Show Postgres Tables

November - 2021

this works from the command line:

psql -d database_name -U role_name -c "\dn"

I'm setup with a local database and postgres role that match my computer login name, so I can just do:

psql -c "\dn"

To see a list of tables in a schema via SQL use:

SELECT * FROM pg_catalog.pg_tables WHERE schemaname = 'the_schema_name';

If you need a list of the schemas to know which one to pick, use:

SELECT * FROM pg_catalog.pg_namespace;