X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 1B95011F6609 for ; Sat, 22 Apr 2006 18:42:54 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.599 X-Spam-Level: X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id cWJ+6Pi-QlOY for ; Sat, 22 Apr 2006 18:42:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from coe.tamu.edu (edsun.coe.tamu.edu [165.91.232.6]) by postgresql.org (Postfix) with ESMTP id AF0C411F662D for ; Sat, 22 Apr 2006 18:42:50 -0300 (ADT) Received: from coe.tamu.edu (coe.tamu.edu [165.91.232.6]) by coe.tamu.edu (8.11.7p1+Sun/8.12.11) with ESMTP id k3MLb7U23274; Sat, 22 Apr 2006 16:37:07 -0500 (CDT) Date: Sat, 22 Apr 2006 16:37:07 -0500 (CDT) From: "Ben K." To: Jeff Frost cc: Bruno Wolff III , pgsql-sql@postgresql.org Subject: Re: find all tables with a specific column name? In-Reply-To: Message-ID: References: <20060421180356.GB13275@wolff.to> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Archive-Number: 200604/152 X-Sequence-Number: 24961 >>> Is there a reasonable way to extract a list of all tables which contain a >>> specific column name from the system views on 8.1? >>> For instance, I might want to enumerate all tables with a column named >>> last_modified. This is nothing new but if I may, may I add for this thread's completeness a try from internal tables? select a.relkind, a.relname from pg_class a inner join pg_attribute b on a.relfilenode = b.attrelid group by a.relkind, a.relname, a.relfilenode,b.attname having b.attname='IID'; The result didn't match the one from the information_schema.tables - the above query included indexes too (relkind=i) while information_schema.tables included only tables and views (r,v). Ben K. Developer http://benix.tamu.edu