Skip site navigation (1) Skip section navigation (2)

Re: Select all table column names for a specified tablename (per the system catalogs)

From: Joshua Drake <jd(at)commandprompt(dot)com>
To: kevin kempter <kevin(at)kevinkempterllc(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Select all table column names for a specified tablename (per the system catalogs)
Date: 2008-09-22 22:29:50
Message-ID: 20080922152950.294284b4@jd-laptop (view raw or flat)
Thread:
Lists: pgsql-admin
On Mon, 22 Sep 2008 16:06:06 -0600
kevin kempter <kevin(at)kevinkempterllc(dot)com> wrote:

> Hi List;
> 
> I want to pull the list of column names from the system catalogs for
> a specified table. I only want column names, I want to exclude any
> index names, or other non-column name rows.  I got this far (see
> below) however this query produces additional rows with attname's
> like tableoid, cmax, xmax ctid, etc.
> 
> select attname from pg_attribute where attrelid = (select oid from  
> pg_class where relname = 'my_tablename');


SELECT column_name FROM information_schema.columns WHERE table_name =
'table';

Joshua D. Drake

> 
> Any thoughts ?
> 
> Thanks in advance...
> 
> 
> 


-- 
The PostgreSQL Company since 1997: http://www.commandprompt.com/ 
PostgreSQL Community Conference: http://www.postgresqlconference.org/
United States PostgreSQL Association: http://www.postgresql.us/
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate



In response to

Responses

pgsql-admin by date

Next:From: Tom LaneDate: 2008-09-23 03:15:29
Subject: Re: displaying enum
Previous:From: kevin kempterDate: 2008-09-22 22:06:06
Subject: Select all table column names for a specified tablename (per the system catalogs)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group