日期:2014-05-17 浏览次数:20906 次
select u1.CONSTRAINT_NAME, u1.TABLE_NAME as table_, u2.TABLE_NAME as reference_ from user_constraints u1, user_constraints u2 where u1.constraint_type='R' and u1.R_CONSTRAINT_NAME = u2.CONSTRAINT_NAME and u2.table_name='target_table_name'
------解决方案--------------------
-- 查询引用父表的所有子表 select c.owner||'.'||c.table_name child_table, c.constraint_name child_constraint_name, (select wm_concat(column_name) from dba_cons_columns where owner=c.owner and constraint_name=c.constraint_name) child_columns, p.owner||'.'||p.table_name parent_table, p.constraint_name parent_constraint_name, (select wm_concat(column_name) from dba_cons_columns where owner=p.owner and constraint_name=p.constraint_name) parent_columns from dba_constraints c,dba_constraints p where p.owner=c.r_owner and p.constraint_name=c.r_constraint_name and p.owner='&parent_owner' and p.table_name='&parent_table';