Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 338E264FC19 for ; Mon, 22 Sep 2008 19:27:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21246-09 for ; Mon, 22 Sep 2008 19:27:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by postgresql.org (Postfix) with ESMTP id 5CE5964FC0A for ; Mon, 22 Sep 2008 19:27:13 -0300 (ADT) Received: from jd-laptop (or-69-34-217-90.sta.embarqhsd.net [69.34.217.90]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m8MMUj15004121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Sep 2008 15:30:46 -0700 Date: Mon, 22 Sep 2008 15:29:50 -0700 From: Joshua Drake To: kevin kempter Cc: pgsql-admin@postgresql.org Subject: Re: Select all table column names for a specified tablename (per the system catalogs) Message-ID: <20080922152950.294284b4@jd-laptop> In-Reply-To: References: Organization: Command Prompt, Inc. X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.9; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Mon, 22 Sep 2008 15:30:46 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/239 X-Sequence-Number: 30332 On Mon, 22 Sep 2008 16:06:06 -0600 kevin kempter 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