Skip site navigation (1) Skip section navigation (2)

Re: How to get table definition of a PostgreSQL table

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: pgsql-interfaces(at)postgresql(dot)org
Cc: Sandeep Khandelwal <sandeep_khandelwal27(at)yahoo(dot)com>
Subject: Re: How to get table definition of a PostgreSQL table
Date: 2006-10-27 10:53:18
Message-ID: 200610270653.18624.sdavis2@mail.nih.gov (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Friday 27 October 2006 02:25, Sandeep Khandelwal wrote:
> Hi.
>
> I would like to get field's name, datatype of each field, length of each
> field and precision of each field of a PostgreSQL table. Please let me SQL
> query to get this information.

See these two chapters in the postgresql docs:

http://www.postgresql.org/docs/8.1/interactive/catalogs.html
http://www.postgresql.org/docs/8.1/interactive/information-schema.html

Each has advantages over the other.

Also, if you start psql with the flag --echo-hidden, when you do commands like 
\dt and \d+, psql will show you the sql it uses to produce that output.

Sean

In response to

pgsql-interfaces by date

Next:From: Brett SchwarzDate: 2006-10-28 16:05:50
Subject: Re: pg_exec commit causes extremely long delays
Previous:From: Sandeep KhandelwalDate: 2006-10-27 06:25:56
Subject: How to get table definition of a PostgreSQL table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group