日期:2014-05-17  浏览次数:20873 次

请教大家 ,我有一张表 ,如何知道哪些表依赖这张表 ,谢谢
请教大家 ,我有一张表 ,如何知道哪些表依赖这张表 ,谢谢

------解决方案--------------------
参考

SQL code

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'

------解决方案--------------------
探讨

参考

SQL code

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_CONSTR……

------解决方案--------------------
SQL code

-- 查询引用父表的所有子表
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';