From: | Greg Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | emilu(at)encs(dot)concordia(dot)ca |
Cc: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: How can I look at a recursive table dependency tree? |
Date: | 2009-05-30 11:07:38 |
Message-ID: | 4136ffa0905300407o1c93bb2csdcf8acd2e15d4a06@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, May 29, 2009 at 5:10 PM, Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:
> Is it possible to find all view names depend on one table?
With 8.4 you can use a query like this (change 'messages' to your table name)
This query could stand to be polished a bit though...
WITH RECURSIVE tree AS (
SELECT 'messages'::regclass::text AS tree,
0 AS level,
'pg_class'::regclass AS classid,
'messages'::regclass AS objid
UNION ALL
SELECT tree || ' <-- ' || get_obj_description(pg_depend.classid,
pg_depend.objid),
level+1,
pg_depend.classid,
pg_depend.objid
FROM tree
JOIN pg_depend ON ( tree.classid = pg_depend.refclassid
AND tree.objid = pg_depend.refobjid)
)
SELECT tree.tree
FROM tree
WHERE level < 10
--
greg
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2009-05-30 12:36:35 | Re: Modifying ENUM Type |
Previous Message | Stefan Kaltenbrunner | 2009-05-30 09:07:54 | Re: Switching databases over JDBC/ODBC |