This is a very easy task, in fact: Oracle maintains the relationships automatically and exposes them through three views. As such, we do not need to rely on reverse engineering DDL scripts.
- USER_DEPENDENCIES returns the dependencies of the objects owned by the current user.
- ALL_DEPENDENCIES returns the dependencies of the objects visible to the current user (so it's a superset of the former)
- DBA_DEPENDENCIES returns the dependencies of the all database objects. It requires SYSDBA privileges.
The most useful fields are returned by the following query:
whose results can be read as "The object name of type type depends on the object referenced_name of type referenced_type owned by referenced_owner (as implied by the use of user_dependencies, the owner of the name object is the current user). The referenced_owner column is useful to filter out various Oracle objects such as DUAL.
select name, type, referenced_owner, referenced_name, referenced_type
from user_dependencies
whose results can be read as "The object name of type type depends on the object referenced_name of type referenced_type owned by referenced_owner (as implied by the use of user_dependencies, the owner of the name object is the current user). The referenced_owner column is useful to filter out various Oracle objects such as DUAL.