9

Using the psql command line tool, how do I list all postgres tables in one particular schema

migrated from serverfault.com Jul 23 '11 at 2:11

This question came from our site for system and network administrators.

16

\dt schemaname.* will do what you want.

2

In addition to the \dt match, you can also look into the database catalog:

SELECT nspname||'.'||relname AS full_rel_name
  FROM pg_class, pg_namespace
 WHERE relnamespace = pg_namespace.oid
   AND nspname = 'yourschemaname'
   AND relkind = 'r';

You can also do it with the more standard information schema, but it tends to be slower:

SELECT table_schema||'.'||table_name AS full_rel_name
  FROM information_schema.tables
 WHERE table_schema = 'yourschemaname';
0

you can run

SELECT * FROM pg_catalog.pg_tables where schemaname="yourschemaname";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy