X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8D3CFD1B1B4 for ; Tue, 18 May 2004 18:44:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 08779-07 for ; Tue, 18 May 2004 18:44:17 -0300 (ADT) Received: from lakermmtao12.cox.net (lakermmtao12.cox.net [68.230.240.27]) by svr1.postgresql.org (Postfix) with ESMTP id 36A4DD1B23C for ; Tue, 18 May 2004 18:44:14 -0300 (ADT) Received: from [192.168.0.13] (really [68.105.167.89]) by lakermmtao12.cox.net (InterMail vM.6.01.03.02 201-2131-111-104-20040324) with ESMTP id <20040518214415.RYOM20240.lakermmtao12.cox.net@[192.168.0.13]>; Tue, 18 May 2004 17:44:15 -0400 From: Robert Treat To: "Scot L. Harris" , Andrew McMillan Subject: Re: table column information Date: Tue, 18 May 2004 17:53:35 -0400 User-Agent: KMail/1.5 Cc: pgsql-php@postgresql.org References: <1084749506.2056.148.camel@lathe> <1084789582.27913.7.camel@lamb.mcmillan.net.nz> <1084829504.2059.187.camel@lathe> In-Reply-To: <1084829504.2059.187.camel@lathe> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200405181753.35869.xzilla@users.sourceforge.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, HTML_TAG_BALANCE_TABLE, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200405/34 X-Sequence-Number: 2753 On Monday 17 May 2004 17:31, Scot L. Harris wrote: > 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 = '' > > > > 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 " 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. A little late to the party, but it seems worth mentioning that this information is also available in the information_schema, which has the benefits of being sql complient, stable across releases, and keeps you out of the system catalogs. for example: cms74=# select column_name from information_schema.columns where table_name = 'current_downloads'; column_name ------------- start_time entity_id (2 rows) for more on information schema check out http://www.postgresql.org/docs/7.4/interactive/information-schema.html Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL