On Fri, May 29, 2009 at 5:10 PM, Emi Lu <emilu@encs.concordia.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