Display or show tables in a PostgreSQL/PgSQL database


From the PostgreSQL psql monitor, use the following command to view the tables in the current database:

\dt

The Conversation

Follow the reactions below and share your own thoughts.

  • noMan

    very old post :(

    • Joe

      So what? Still worked for me…

  • Marek Pe

    You can receive column comments in SQL:

    SELECT a.attname AS column, d.description AS COMMENT
    FROM pg_class c
    JOIN pg_description d ON c.oid=d.objoid
    JOIN pg_attribute a ON c.oid = a.attrelid
    WHERE c.relname=’monitors’
    AND a.attnum = d.objsubid

  • Guest

    select
    ordinal_position,
    column_name,
    data_type,
    is_nullable,
    description.description as comment
    from
    information_schema.columns columns
    left join pg_class class on (columns.table_name = class.relname)
    left join pg_description description on (class.oid = description.objoid)
    left join pg_attribute attrib on (class.oid = attrib.attrelid and columns.column_name = attrib.attname and attrib.attnum = description.objsubid)
    where
    table_name='{$tableName}’
    group by
    ordinal_position, column_name, data_type, is_nullable, description.description

  • runa

    Thanks :) It worked

  • http://revistacincoletras.com/ Taller de creación literaria cinco letras

    not working :s

  • http://revistacincoletras.com/ Taller de creación literaria cinco letras

    Never mind, I did´t selected the db