Find the Dependencies for the Objects in Oracle
For finding the dependencies, we used the HR demo schema for showing the example of employee table in Oracle.
Check dependencies for table name
col owner for a20
col name for a20
col type for a10
col referenced_type for 20
col referenced_owner for a20
col referenced_name for a20
select * from dba_dependencies where referenced_owner = '&USER_NAME' and referenced_name = '&OBJECT_NAME';
OR
Select TYPE || ' ' || OWNER || '.' || NAME || ' references ' ||
REFERENCED_TYPE || ' ' || REFERENCED_OWNER || '.' || REFERENCED_NAME
as DEPENDENCIES From all_dependencies
Where REFERENCED_NAME = UPPER(LTRIM(RTRIM( '&ls_REF_name' )))
AND (REFERENCED_OWNER <> 'SYS' AND REFERENCED_OWNER <> 'SYSTEM' AND REFERENCED_OWNER <> 'PUBLIC')
AND (OWNER <> 'SYS' AND OWNER <> 'SYSTEM' AND OWNER <> 'PUBLIC')
order by OWNER, name,REFERENCED_TYPE ,REFERENCED_OWNER ,REFERENCED_name;
Enter value for ls_ref_name: EMPLOYEES
OUTPUT:
VIEW HR.EMP_DETAILS_VIEW references TABLE HR.EMPLOYEES
TRIGGER HR.SECURE_EMPLOYEES references TABLE HR.EMPLOYEES
TRIGGER HR.UPDATE_JOB_HISTORY references TABLE HR.EMPLOYEES
Check dependencies on procedure, trigger, packages and functions
col owner for a20
col name for a20
col type for a10
col referenced_type for 20
col referenced_owner for a20
col referenced_name for a20
select * from dba_dependencies where owner='&SCHEMA_NAME' and name='&OBJECT_NAME';
OR
Select TYPE || ' ' || OWNER || '.' || NAME || ' references ' ||
REFERENCED_TYPE || ' ' || REFERENCED_OWNER || '.' || REFERENCED_NAME
as DEPENDENCIES From all_dependencies
Where name = UPPER(LTRIM(RTRIM( '&ls_REF_name' )))
AND (REFERENCED_OWNER <> 'SYS' AND REFERENCED_OWNER <> 'SYSTEM' AND REFERENCED_OWNER <> 'PUBLIC')
AND (OWNER <> 'SYS' AND OWNER <> 'SYSTEM' AND OWNER <> 'PUBLIC')
order by OWNER, name,REFERENCED_TYPE ,REFERENCED_OWNER ,REFERENCED_name;
Enter value for ls_ref_name: UPDATE_JOB_HISTORY
OUTPUT:
TRIGGER HR.UPDATE_JOB_HISTORY references PROCEDURE HR.ADD_JOB_HISTORY
TRIGGER HR.UPDATE_JOB_HISTORY references TABLE HR.EMPLOYEES