Does this help?
Will, April 18, 2007 - 4:22 am UTC
I've had to do something similar in the past, and used a query similar to this. It uses an analytic function to create a pivotted column for composite foreign keys. In this case I already knew that such keys had a maximum of 2 columns, but you could probably expand the idea.
It's simplified somewhat to remove some clutter. And probably inefficent, but then I only had to run it once.
Tom, I await your critique!
select
uc.table_name tn,
uc.constraint_name cn,
uc.constraint_type,
uc.r_constraint_name,
ucc.table_name rtn,
ucc.column_name child_column1,
ucc.constraint_name,
ucc.position,
lead(ucc.column_name) over (partition by uc.constraint_name, uc.table_name order by ucc.position) child_column2
from
user_constraints uc
inner join user_cons_columns ucc
on uc.r_constraint_name = ucc.constraint_name and uc.constraint_type = 'R' and uc.owner = ucc.owner
order by uc.table_name, uc.constraint_name, ucc.position
April 18, 2007 - 12:07 pm UTC
if it works, it works - I have my script (cons.sql) which I'll continue to use... and dbms_metadata