How to show Postgres table information

Here you want to use the "describe" command in Postgresql. Assuming that you want to get information about a database table named users, and you're logged into a Postgresql database using the psql client, issue this command at the psql prompt:

\d users

This will provide a description of the table named users. Your output from this command should look like this:

mydatabase=> \d users

                             Table "public.users"
    Column    |          Type          |              Modifiers
 user_id      | integer                | not null default 
 username     | character varying(24)  | not null
 firstname    | character varying(24)  | not null
 lastname     | character varying(24)  | not null
 companyname  | character varying(24)  |
 password     | character varying(255) | not null
 email_addr   | character varying(24)  | not null
    "users_pkey" PRIMARY KEY, btree (user_id)

Of course the fields in your database will be different, but the output should appear similar.

This output was generated with the psql client for Postgresql 8.0.3.

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.