I need help with a pretty basic Postgres command, but I cannot find a reference anywhere. My cluster is set up like this:
database_1
\- schema_1
\- schema_2
\- relation_1
\- relation_2
\- ...
\- relation_3
\- relation_4
\- ...
I know how to list databases (\l
), and I know how to list relations in the "default" schema (\dt
). Heck, I can even list schemas (\dn
), but I cannot, for开发者_StackOverflow the life of me, list the relations within a schema.
Halp!
Thanks, Joe
To pre-clarify, what I'm looking for is this:
> \c database_1
You are now connected to database_1
> \somecommand
relation_1
relation_2
>
Try this one:
\dt schema_2.
I'll clarify since this is the first result of a google search.
\dt schema_2
will not list all the relations for schema_2
.
The correct answer is in the comments of the answer.
\dt schema_2.*
A more thorough answer can be found here, List tables in a PostgreSQL schema
As of PostgresQL version 11.2 I find that this performs as expected. It lists views and sequences as well, not just tables.
\d schema_2.
If you replace schema_2 with your schema name and leave the dot it appears to work fine.
Some further command instructions are available in a psql connection via \?
精彩评论