pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scot L. Harris <webid@cfl.rr.com>
To: Andrew McMillan <andrew@catalyst.net.nz>
Cc: pgsql-php@postgresql.org
Subject: Re: table column information
Date: Mon, 17 May 2004 17:31:44 -0400
Message-ID: <1084829504.2059.187.camel@lathe> (raw)
In-Reply-To: <1084789582.27913.7.camel@lamb.mcmillan.net.nz>
References: <1084749506.2056.148.camel@lathe>
	<c890e8$12ql$1@news.hub.org>
	<1084762532.4822.36.camel@lamb.mcmillan.net.nz>
	<1084763775.2058.173.camel@lathe>
	<1084789582.27913.7.camel@lamb.mcmillan.net.nz>

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>




view thread (11+ messages)  latest in thread

Message-ID: <1084829504.2059.187.camel@lathe>
Permalink:  ../1084829504.2059.187.camel@lathe/
Also on:    postgresql.org/message-id/1084829504.2059.187.camel@lathe

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: webid@cfl.rr.com, andrew@catalyst.net.nz
  Subject: Re: table column information
  In-Reply-To: <1084829504.2059.187.camel@lathe>
  References: <1084749506.2056.148.camel@lathe> <c890e8$12ql$1@news.hub.org> <1084762532.4822.36.camel@lamb.mcmillan.net.nz> <1084763775.2058.173.camel@lathe> <1084789582.27913.7.camel@lamb.mcmillan.net.nz> <1084829504.2059.187.camel@lathe>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox