日期:2014-05-16  浏览次数:20520 次

.查询ORACLE的外键关联
select
a.constraint_name 关系,
a.owner 外键拥有者,
a.table_name 外键表,
c.column_name 外键列,
b.owner 主键拥有者,
b.table_name 主键表,
d.column_name 主键列
from
user_constraints a,
user_constraints b,
user_cons_columns c,
user_cons_columns d
where
    a.r_constraint_name=b.constraint_name
and a.constraint_type='R'
and b.table_name = 'WORKGROUPS'
and b.constraint_type='P'
and a.r_owner=b.owner
and a.constraint_name=c.constraint_name
and b.constraint_name=d.constraint_name
and a.owner=c.owner
and a.table_name=c.table_name
and b.owner=d.owner
and b.table_name=d.table_name
and c.column_name = d.column_name ;