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

Re: Field list from table

From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Field list from table
Date: 2004-02-26 13:08:56
Message-ID: m365duyolz.fsf@wolfe.cbbrowne.com (view raw or flat)
Thread:
Lists: pgsql-sql
"Jan Pips" <jan_pips(at)op(dot)pl> wrote:
> How can I, using SELECT, get the full list of fields from a given table?

portfolio=# select column_name, data_type from information_schema.columns where table_catalog = 'portfolio' and table_schema = 'public' and table_name = 'stocktxns';
 column_name |        data_type         
-------------+--------------------------
 symbol      | character varying
 date        | timestamp with time zone
 price       | numeric
 quantity    | numeric
(4 rows)

information_schema.columns has additional columns to provide
information about numeric precision, string widths, and such...
-- 
"cbbrowne","@","ntlug.org"
http://www.ntlug.org/~cbbrowne/postgresql.html
Rules  of the  Evil Overlord  #4.  "Shooting is  not too  good for  my
enemies." <http://www.eviloverlord.com/>

In response to

pgsql-sql by date

Next:From: KumarDate: 2004-02-26 13:51:37
Subject: Return more than a record
Previous:From: Philip J. BoonzaaierDate: 2004-02-26 10:18:57
Subject: Triggers

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