Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id CFF599FA485 for ; Tue, 26 Dec 2006 16:27:33 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 80885-05 for ; Tue, 26 Dec 2006 16:27:29 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id E233F9F9F46 for ; Tue, 26 Dec 2006 16:27:28 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net [216.204.66.226]) by svr4.postgresql.org (Postfix) with ESMTP id 66EA55AF043 for ; Tue, 26 Dec 2006 20:27:28 +0000 (GMT) Received: from JIMSDELL2 (c-75-68-77-33.hsd1.nh.comcast.net [75.68.77.33]) (authenticated bits=0) by amanda.contactbda.com (8.13.8/8.13.8/Debian-2) with ESMTP id kBQKR80j031116; Tue, 26 Dec 2006 15:27:15 -0500 Message-Id: <200612262027.kBQKR80j031116@amanda.contactbda.com> From: "Jim Buttafuoco" To: "'Jan Meyland Andersen'" , "'Michael Fuhr'" Cc: Subject: Re: Related tables to a view Date: Tue, 26 Dec 2006 15:27:03 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Thread-Index: AccpKfciHhaOWRKDSwm0x2Iwiq1qRgAAiY/Q In-reply-to: <1260.62.66.218.59.1167163837.squirrel@mail.agile.dk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/173 X-Sequence-Number: 27129 Try this query select a.relname as base,a.relkind from pg_class a join pg_depend d on (a.oid = d.refobjid) join pg_class c on (d.classid = c.oid) join pg_rewrite r on (objid = r.oid) join pg_class v on (ev_class = v.oid) where a.relkind in('r', 'v') and a.relname <> v.relname and v.relname='YOUR VIEW NAME HERE' order by 1 -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Jan Meyland Andersen Sent: Tuesday, December 26, 2006 3:11 PM To: Michael Fuhr Cc: Jan Meyland Andersen; pgsql-sql@postgresql.org Subject: Re: [SQL] Related tables to a view > You could query pg_depend to find out which tables and columns the > view's rewrite rule depends on but that's not as specific as what > you're requesting. I'm not aware of a way to associate a particular > table column with a particular view column short of parsing the view > definition or rule action; doing so would have to allow for the > possibility of a view column deriving its value from an arbitrarily > complex expression involving multiple tables, subqueries, etc. I have been thinking the problem through again, and I think I am able to solve the problem if I just know which tables the view is using. But how do I get this information from the pg_depend table? Regards Jan ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend