Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 974FE2E3343 for ; Wed, 6 Feb 2008 16:33:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 79538-09 for ; Wed, 6 Feb 2008 16:33:31 -0400 (AST) Received: from starfish.geekisp.com (mail.geekisp.com [216.168.135.169]) by postgresql.org (Postfix) with ESMTP id 8B2B52E01F8 for ; Wed, 6 Feb 2008 16:33:34 -0400 (AST) Received: (qmail 4564 invoked by uid 1003); 6 Feb 2008 20:34:58 -0000 Received: from adsl-76-200-128-121.dsl.pltn13.sbcglobal.net (HELO dino-1.misuse.org) (public@misuse.org@76.200.128.121) by mail.geekisp.com with (DHE-RSA-AES256-SHA encrypted) SMTP; 6 Feb 2008 20:34:58 -0000 X-Mailer: QUALCOMM Windows Eudora Version 7.1.0.9 Date: Wed, 06 Feb 2008 12:33:25 -0800 To: pgsql-sql@postgresql.org From: Steve Midgley Subject: Columns view? (Finding column names for a table) Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Message-Id: <20080206203334.8B2B52E01F8@postgresql.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/34 X-Sequence-Number: 30125 Hi, I see this documentation item but can't figure out how to use it: http://www.postgresql.org/docs/8.2/interactive/infoschema-columns.html >The view columns contains information about all table columns (or view >columns) in the database. However, if I execute "select columns;" I get a not found error. I'm sure there's some simple explanation - I'm interested specifically in listing the column names of a specific table (in Pg 8.2). The manual SQL I've developed is (where [table_name] is the table I want columns for): select pg_attribute.attname, * from pg_attribute join pg_class on pg_class.oid = pg_attribute.attrelid where pg_class.relname = '[table_name]' and attnum > 0 and atttypid > 0 Not pretty but seems to work. Of course if there were a view that encapsulated this and future-proofed it, that'd be much nicer. Any assistance is appreciated! Thanks, Steve