• Recent blogs

    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:


    Programmatically (or from the psql interface too, of course):

    SELECT * FROM pg_catalog.pg_tables;

    Now in Psql you could run commands such as:

    1. \? list all the commands
    2. \l list databases
    3. \conninfo display information about current connection
    4. \c [DBNAME] connect to new database, e.g., \c template1
    5. \dt list tables of the public schema
    6. \dt <schema-name>.* list tables of certain schema, e.g., \dt public.*
    7. \dt *.* list tables of all schemas
    8.  Then you can run SQL statements, e.g., SELECT * FROM my_table;(Note: a   statement must be terminated with semicolon ;)
    9. \q quit psql

    No comments