Find all dependent objects for a given object in postgres

40 views Asked by At

I have a view and MVs with me. I need a query that can provide a list of views and MVs that are dependent on a particular view or MV.

eg I have view A. I need a complete list of objects dependent on A.

data1 > finding oid of view 
data2 > using oid from data1  as refid finding depending oid 
last query trying to find dependent objects but not getting result.

Does objid from pg_Depend does not give id of dependent objects

with data1 as (select oid  from  pg_class AS v WHERE v.relkind  in ( 'v')
  and relname='A'),
 data2 as (select distinct  d.objid from pg_depend AS d join data1 as dd
 on d.refobjid =dd.oid
 ) 
 select c.*  from pg_class as c join data2 as dd 
 on(c.oid =dd.objid )
0

There are 0 answers