Skip to content

Instantly share code, notes, and snippets.

@marcosvidolin
Created January 5, 2018 17:33
Show Gist options
  • Save marcosvidolin/d7c5cefd0e2fb61a78ba381523d6d59b to your computer and use it in GitHub Desktop.
Save marcosvidolin/d7c5cefd0e2fb61a78ba381523d6d59b to your computer and use it in GitHub Desktop.
How to see all references for a FK
SELECT a.table_name, a.column_name, a.constraint_name, c.owner,
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.COLUMN_NAME = '<COLUMN_NAME>' and c.owner = '<OWNER_NAME>'
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment