Search Postgresql Archives

Re: How can I look at a recursive table dependency tree?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux