Skip to content

Instantly share code, notes, and snippets.

@terrancesnyder
Created November 14, 2011 14:01
Show Gist options
  • Save terrancesnyder/1364004 to your computer and use it in GitHub Desktop.
Save terrancesnyder/1364004 to your computer and use it in GitHub Desktop.
Foreign Keys in Oracle Schema
SELECT a.table_name, a.column_name, uc.table_name, uc.column_name
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
join USER_CONS_COLUMNS uc on uc.constraint_name = c.r_constraint_name
WHERE C.R_OWNER = 'CLIP_DEV'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment