Last active
May 12, 2026 17:06
-
-
Save wellington1993/30121c95ce80f7ec44bdabbd6b0b4e3f to your computer and use it in GitHub Desktop.
Oracle find Foreign Keys and dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select * | |
| from all_constraints | |
| where r_constraint_name in ( | |
| select constraint_name | |
| from all_constraints | |
| where table_name = :TableName | |
| ) | |
| --- | |
| SELECT owner, table_name, constraint_name, r_constraint_name | |
| FROM dba_constraints | |
| WHERE table_name = :TableName | |
| --- | |
| SELECT a.table_name, a.column_name, a.constraint_name, c.owner, | |
| -- referenced pk | |
| c.r_owner, c_pk.table_name r_table_name, c_pk.constraint_name r_pk | |
| FROM all_cons_columns a | |
| JOIN all_constraints c ON a.owner = c.owner | |
| AND a.constraint_name = c.constraint_name | |
| JOIN all_constraints c_pk ON c.r_owner = c_pk.owner | |
| AND c.r_constraint_name = c_pk.constraint_name | |
| WHERE c.constraint_type = 'R' | |
| AND a.table_name = :TableName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment