首页  :: 新随笔  :: 管理

Oracle查找表的外键引用关系

Posted on 2015-10-23 09:35  季枫  阅读(2100)  评论(0编辑  收藏  举报

Oracle查找表的外键引用关系 

select t1.table_name, 
       t2.table_name as "TABLE_NAME(R)", 
       t1.constraint_name, 
       t1.r_constraint_name as "CONSTRAINT_NAME(R)",
       a1.column_name, 
       a2.column_name as "COLUMN_NAME(R)"
from user_constraints t1, user_constraints t2, user_cons_columns a1, user_cons_columns a2 
where t1.owner = upper('DCI') and 
      t1.r_constraint_name = t2.constraint_name and 
      t1.constraint_name = a1.constraint_name and 
      t1.r_constraint_name = a2.constraint_name;
DCI是用户名称


查看被视图或者触发器、存储过程使用过:
select * from user_dependencies t where t.referenced_name = 'TABLE_NAME';

  

智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |