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: (view raw, whole thread or download thread mbox)
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...
Rules  of the  Evil Overlord  #4.  "Shooting is  not too  good for  my
enemies." <>

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-2017 The PostgreSQL Global Development Group