Created
July 3, 2012 08:26
-
-
Save mvaz/3038473 to your computer and use it in GitHub Desktop.
Oracle: list foreign key constraints
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 | |
| col.table_name || '.' || col.column_name as foreign_key, | |
| rel.table_name || '.' || rel.column_name as references | |
| from | |
| user_tab_columns col | |
| join user_cons_columns con | |
| on col.table_name = con.table_name | |
| and col.column_name = con.column_name | |
| join user_constraints cc | |
| on con.constraint_name = cc.constraint_name | |
| join user_cons_columns rel | |
| on cc.r_constraint_name = rel.constraint_name | |
| and con.position = rel.position | |
| where | |
| cc.constraint_type = 'R' | |
| ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment