Re: Getting fields in a table through a query?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mitch Vincent" <mitch(at)doot(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting fields in a table through a query?
Date: 2002-02-05 15:44:21
Message-ID: 24946.1012923861@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Mitch Vincent" <mitch(at)doot(dot)org> writes:
> How can I get the fields in a given table via an SQL query even if there are
> no records in that table? I just need the names of all the fields in a
> table -- is that even possible?

Why not just
select * from foo where false;
and examine the column names that come back? Lack of any data will not
stop the system from sending column headers.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-02-05 15:50:08 Re: rule on update
Previous Message Ben-Nes Michael 2002-02-05 14:17:25 caculating while select - maybe sum ?