By Alvin Alexander. Last updated: June 30, 2021
To show Postgres table information, use the "describe" command. 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
. As an example, your output from this command should look like this:
mydatabase=> \d users Table "public.users" Column | Type | Modifiers --------------+------------------------+------------------------------------ user_id | integer | not null default nextval('"users_user_id_seq"'::text) 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 Indexes: "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.