转,Oracle查询外键关联
程序员文章站
2022-04-21 10:32:33
...
select aaa.owner 外键库,
aaa.table_name 外键表,
substr(c.column_name, 1, 127) 外键列,
bb.owner 主键库,
bb.table_name 主键表,
substr(d.column_name, 1, 127) 主键列
from user_constraints aaa,
user_constraints bb,
user_cons_columns c,
user_cons_columns d
where aaa.r_constraint_name = bb.constraint_name
and aaa.constraint_type = 'R'
and bb.constraint_type = 'P'
and aaa.r_owner = bb.owner
and aaa.constraint_name = c.constraint_name
and bb.constraint_name = d.constraint_name
and aaa.owner = c.owner
and aaa.table_name = c.table_name
and bb.owner = d.owner
and bb.table_name = d.table_name
下一篇: BlockingQueue