Re: table column information - Mailing list pgsql-php

From Scot L. Harris
Subject Re: table column information
Date
Msg-id 1084829504.2059.187.camel@lathe
Whole thread Raw
In response to Re: table column information  (Andrew McMillan <andrew@catalyst.net.nz>)
Responses Re: table column information  (Robert Treat <xzilla@users.sourceforge.net>)
List pgsql-php
On Mon, 2004-05-17 at 06:26, Andrew McMillan wrote:
> On Sun, 2004-05-16 at 23:16 -0400, Scot L. Harris wrote:
> > >
> > > You can also select the column names from the database metadata
> > > directly:
> > >
> > > SELECT attname
> > >   FROM pg_class c join pg_attribute a on c.oid = a.attrelid
> > >   WHERE c.relname = '<your table name>'
> > >     AND a.attnum >= 0;
> > >
> > > This approach won't get killed by the efficiency problems above.
> > >
> > > Cheers,
> > >                     Andrew.
> >

> When I want to figure out something like this I tend to use "psql -E" so
> that all queries are echoed before being sent to the backend.  Then I do
> something like "\d <table>" and see what SQL psql generates internally.
>
> Also, dig here for detailed information on the postgresql data
> dictionary tables:
>
> http://www.postgresql.org/docs/7.4/interactive/catalogs.html
>
> the most useful ones are pg_class and pg_attribute usually (for obvious
> reasons :-).  With 7.4 I also find myself looking at the
> pg_stat_activity view from time to time as well.
>
> Cheers,
>                     Andrew.


Thanks to everyone that responded to my question.  I have my application
working as I wanted.  I really appreciate all the help that was
provided.


--
Scot L. Harris <webid@cfl.rr.com>


pgsql-php by date:

Previous
From: Steve Crawford
Date:
Subject: Re: table column information
Next
From: Robert Treat
Date:
Subject: Re: table column information