Created
May 19, 2016 11:04
-
-
Save haisum/d5d8da055c6d21b0d28190e3f972a803 to your computer and use it in GitHub Desktop.
Find all foreign key reference to a table in oracle
This file contains 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 | |
src_cc.owner as src_owner, | |
src_cc.table_name as src_table, | |
src_cc.column_name as src_column, | |
dest_cc.owner as dest_owner, | |
dest_cc.table_name as dest_table, | |
dest_cc.column_name as dest_column, | |
c.constraint_name | |
from | |
all_constraints c | |
inner join all_cons_columns dest_cc on | |
c.r_constraint_name = dest_cc.constraint_name | |
and c.r_owner = dest_cc.owner | |
inner join all_cons_columns src_cc on | |
c.constraint_name = src_cc.constraint_name | |
and c.owner = src_cc.owner | |
where | |
c.constraint_type = 'R' | |
and dest_cc.owner = 'MY_TARGET_SCHEMA' | |
and dest_cc.table_name = 'MY_TARGET_TABLE' | |
--and dest_cc.column_name = 'MY_OPTIONNAL_TARGET_COLUMN' | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment