From: | Jason Earl <jason(dot)earl(at)simplot(dot)com> |
---|---|
To: | Mike Blackwell <mblackwell(at)wallace(dot)com> |
Cc: | "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Getting list of columns in a table |
Date: | 2002-09-18 19:44:59 |
Message-ID: | 87lm5z9j5w.fsf@npa01zz001.simplot.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The trick is to fire up psql with -E flag. That causes psql to spit
out the SQL it uses to query the system tables for things like:
\d tablename
I believe that the query you need is:
SELECT a.attname
FROM pg_class c, pg_attribute a
WHERE c.relname = 'schedule'
AND a.attnum > 0 AND a.attrelid = c.oid
ORDER BY a.attnum;
Jason
Mike Blackwell <mblackwell(at)wallace(dot)com> writes:
> Sorry if this is a FAQ, but didn't see it in the web site FAQ or in the
> docs I have.
>
> I need a SQL statement which will return a list of the column names for
> a (possibly empty) table. FWIW, I'm using Perl and DBI.
>
> TiA,
> Mike
> mblackwell(at)wallace(dot)com
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Boes | 2002-09-18 19:51:41 | Database uptime? |
Previous Message | Mike Blackwell | 2002-09-18 19:13:46 | Getting list of columns in a table |