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 8022211F6B85 for ; Fri, 21 Apr 2006 15:32:04 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.498 X-Spam-Level: X-Spam-Status: No, score=-2.498 required=5 tests=[AWL=0.100, BAYES_00=-2.599, UNPARSEABLE_RELAY=0.001] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id NHRArwPj04xU for ; Fri, 21 Apr 2006 15:31:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by postgresql.org (Postfix) with ESMTP id CB53011F6B75 for ; Fri, 21 Apr 2006 15:31:53 -0300 (ADT) Received: (from smtp@localhost) by ll.mit.edu (8.12.10/8.8.8) id k3LIVqPx001848 for ; Fri, 21 Apr 2006 14:31:52 -0400 (EDT) Received: from UNKNOWN( ), claiming to be "sty.llan" via SMTP by llmail, id smtpdAAAj2aand; Fri Apr 21 14:31:41 2006 Date: Fri, 21 Apr 2006 14:31:41 -0400 From: George Young To: pgsql-sql@postgresql.org Subject: Re: find all tables with a specific column name? Message-Id: <20060421143141.1f3681fb.gry@ll.mit.edu> In-Reply-To: References: Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.0; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/150 X-Sequence-Number: 24959 I've found it useful to explore the information_schema schema by doing: set search_path=information_schema; -- Lets just look at the system tables. \d -- Show me all the tables. ... (40 rows) then select * from some-likely-looking-table limit 20; In this case, I quickly found a table called "columns", so you can do: select table_name from information_schema.columns where column_name='last_modified'; Of course you could be a wuss and actually read the documentation ;-) http://www.postgresql.org/docs/8.1/interactive/infoschema-columns.html -- George Young On Fri, 21 Apr 2006 09:29:33 -0700 (PDT) Jeff Frost wrote: > 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. > > -- > Jeff Frost, Owner > Frost Consulting, LLC http://www.frostconsultingllc.com/ > Phone: 650-780-7908 FAX: 650-649-1954 > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > -- "Are the gods not just?" "Oh no, child. What would become of us if they were?" (CSL)