Show Postgres Tables

this works from the command line:

Code
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:

Code
psql -c "\dn"

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

Code
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:

Code
SELECT * FROM pg_catalog.pg_namespace;

One you have the tables you can look at the structure with:

Code
SELECT *
FROM information_schema.columns
WHERE table_name = 'example_table';

If you're using the `psql` client on the command line, you can also do:

Code
\c example_table