Tuesday, May 1, 2012

Query to find unused (not referenced in other DB packages, procedures, function) package

Following query can be used to find unused (not referenced in other DB packages, procedures, function) packages. Packages can still be used in DBMS Jobs / Scheduler Jobs / Application select distinct owner || '.' || name from dba_DEPENDENCIES where name in ( select referenced_name from dba_DEPENDENCIES where type != 'SYNONYM' and owner in ('SCOTT', 'SCOTT2') group by referenced_name having count(*) = 1) and owner in ('SCOTT', 'SCOTT2') and type in ('PACKAGE BODY', 'PACKAGE') order by 1