Oracle DB: Object dependencies

Here is how to query the dependencies of an object in Oracle DB:

(in this example, which tables a package specification is depended on)

select  /*+ NO_PARALLEL */ * from (
SELECT DISTINCT
b.object_name as NAME,
   b.owner,
   b.object_type TYPE,
   B.OBJECT_ID,
   b.status,
   replace(b.object_type,' ','_') type_link,
   b.owner sdev_link_owner,
   b.object_name sdev_link_name,
   b.object_type sdev_link_type
FROM
   sys.all_objects b,
   (SELECT object_id, referenced_object_id, level l, rownum ord
    FROM public_dependency
    START WITH object_id in (select object_id from all_objects
                                          where object_name = 'TEST_PKG'
                                          and object_type='PACKAGE' /* PACKAGE BODY */)
    CONNECT BY NOCYCLE PRIOR referenced_object_id = object_id) c
WHERE b.object_id = c.referenced_object_id
AND b.owner NOT IN ('SYS', 'SYSTEM')
AND b.object_name <> 'DUAL'
--order by ord
 )  WHERE TYPE  = 'TABLE'

Leave a Reply