How to show tables in PostgreSQL?
You can use PostgreSQL's interactive terminal Psql to show tables in PostgreSQL.
First, choose your database
\c database_name
Then, this shows all tables in the current schema:
\dt
Programmatically (or from the psql
interface too, of course):
SELECT * FROM pg_catalog.pg_tables;
Now in Psql you could run commands such as:
\?
list all the commands \l
list databases \conninfo
display information about current connection \c [DBNAME]
connect to new database, e.g., \c template1
\dt
list tables of the public schema \dt <schema-name>.*
list tables of certain schema, e.g., \dt public.*
\dt *.*
list tables of all schemas- Then you can run SQL statements, e.g.,
SELECT * FROM my_table;
(Note: a statement must be terminated with semicolon ;
) \q
quit psql
No comments