pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sean Davis <sdavis2@mail.nih.gov>
To: pgsql-interfaces@postgresql.org
Cc: Sandeep Khandelwal <sandeep_khandelwal27@yahoo.com>
Subject: Re: How to get table definition of a PostgreSQL table
Date: Fri, 27 Oct 2006 06:53:18 -0400
Message-ID: <200610270653.18624.sdavis2@mail.nih.gov> (raw)
In-Reply-To: <20061027062556.97956.qmail@web33305.mail.mud.yahoo.com>
References: <20061027062556.97956.qmail@web33305.mail.mud.yahoo.com>

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



view thread (3+ messages)  latest in thread

Message-ID: <200610270653.18624.sdavis2@mail.nih.gov>
Permalink:  ../200610270653.18624.sdavis2@mail.nih.gov/
Also on:    postgresql.org/message-id/200610270653.18624.sdavis2@mail.nih.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: sdavis2@mail.nih.gov, sandeep_khandelwal27@yahoo.com
  Subject: Re: How to get table definition of a PostgreSQL table
  In-Reply-To: <200610270653.18624.sdavis2@mail.nih.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox