From: Jim Buttafuoco <jim@contactbda.com>
To: 'Jan Meyland Andersen' <jma@agile.dk>
To: 'Michael Fuhr' <mike@fuhr.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Related tables to a view
Date: Tue, 26 Dec 2006 15:27:03 -0500
Message-ID: <200612262027.kBQKR80j031116@amanda.contactbda.com> (raw)
In-Reply-To: <1260.62.66.218.59.1167163837.squirrel@mail.agile.dk>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jim@contactbda.com, jma@agile.dk, mike@fuhr.org
Subject: Re: Related tables to a view
In-Reply-To: <200612262027.kBQKR80j031116@amanda.contactbda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox