Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id DCBAA9FB2C3 for ; Fri, 19 Jan 2007 08:46:25 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 24372-06 for ; Fri, 19 Jan 2007 08:46:17 -0400 (AST) X-Greylist: delayed 00:05:01.701746 by SQLgrey-1.7.4 Received: from kcout03.prserv.net (kcout03.prserv.net [12.154.55.33]) by postgresql.org (Postfix) with ESMTP id 0DE929FB2A3 for ; Fri, 19 Jan 2007 08:46:21 -0400 (AST) Received: from kcbe02 (kcbe02.backbone.kan[10.254.3.142]) by prserv.net (kcout03) with SMTP id <2007011912411820300mqa5ue>; Fri, 19 Jan 2007 12:41:18 +0000 X-Originating-IP: [10.254.3.142] From: paallen@attglobal.net To: pgsql-sql@postgresql.org, Subject: Query to return schema/table/columname/columntype Date: Fri, 19 Jan 2007 12:41:19 +0000 X-Priority: 3 MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <20070119124622.0DE929FB2A3@postgresql.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.555 tagged_above=0 required=5 tests=BAYES_50, DNS_FROM_RFC_ABUSE, MSGID_FROM_MTA_ID, NO_REAL_NAME X-Spam-Level: ** X-Archive-Number: 200701/78 X-Sequence-Number: 27230 Hi all, I am trying to modify the dabo (a python wxpython ide for database forms creation) code to allow the selection of tables in any schema. I need a query that will return records with schema, table, columname and columne type. For background I am selecting table & schema by the query: SELECT schemaname || '.' || tablename AS tablename FROM pg_tables ORDER BY tablename; Then I need to obtain the columns within that table/schema. The original query was: select c.oid,a.attname, t.typname from pg_class c inner join pg_attribute a on a.attrelid = c.oid inner join pg_type t on a.atttypid = t.oid where c.relname = 'thetablename and a.attnum > 0; Now my problem is how to create a new column to replace c.relname so I can query on "theschemaname.thetablename". Any suggestions will be welcomed. Thanks, Phil