Skip to content

Instantly share code, notes, and snippets.

@mvaz
Created July 3, 2012 08:26
Show Gist options
  • Select an option

  • Save mvaz/3038473 to your computer and use it in GitHub Desktop.

Select an option

Save mvaz/3038473 to your computer and use it in GitHub Desktop.
Oracle: list foreign key constraints
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