-- 查询父表关联外键
select c.constraint_name,cc.column_name,rcc.owner,rcc.table_name,rcc.column_name
from user_constraints c,user_cons_columns cc,user_cons_columns rcc
where c.owner='DEV_MST'
and c.table_name ='ITEM_MASTER'
and c.constraint_type='R'
and c.owner=cc.owner
and c.constraint_name=cc.constraint_name
and c.r_owner=rcc.owner
and c.r_constraint_name=rcc.constraint_name
and cc.position=rcc.position
order by c.constraint_name,cc.position;
--查询子表关联外键
select rcc.owner,rcc.table_name,rcc.constraint_name,rcc.column_name,c.table_name,c.constraint_name,cc.column_name
from user_constraints c,user_cons_columns cc,user_cons_columns rcc
where c.owner='DEV_MST'
and rcc.table_name ='ITEM_MASTER'
and c.constraint_type='R'
and c.owner=cc.owner
and c.constraint_name=cc.constraint_name
and c.r_owner=rcc.owner
and c.r_constraint_name=rcc.constraint_name
and cc.position=rcc.position
order by c.constraint_name,cc.position
-- PK和唯一索引
select c.constraint_name,c.constraint_type,cc.column_name
from user_constraints c,user_cons_columns cc
where c.owner='DEV_MST'
and c.table_name ='ITEM_MASTER'
and c.owner=cc.owner
and c.constraint_name=cc.constraint_name
and c.constraint_type in ('P','U')
order by c.constraint_type,c.constraint_name,cc.position;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8058892/viewspace-752637/ ,如需转载,请注明出处,否则将追究法律责任。