签到成功

知道了

CNDBA社区CNDBA社区

显示表的外键信息

2017-02-24 17:39 2587 0 原创 常用脚本
作者: dave

col search_condition format a54
select table_name,constraint_name from user_constraints 
where constraint_type ='R' and constraint_name in (select constraint_name from user_cons_columns where column_name='&1');


select rpad(child.table_name,25,' ') child_tablename,
rpad(cp.column_name,17,' ') referring_column,rpad(parent.table_name,25,' ') parent_tablename,
rpad(pc.column_name,15,' ') referred_column,rpad(child.constraint_name,25,' ') constraint_name 
from user_constraints child,user_constraints parent,user_cons_columns cp,user_cons_columns pc 
where child.constraint_type = 'R' and child.r_constraint_name = parent.constraint_name and
child.constraint_name = cp.constraint_name and parent.constraint_name = pc.constraint_name and
cp.position = pc.position and child.table_name ='&table_name'
order by child.owner,child.table_name,child.constraint_name,cp.position; 

http://www.cndba.cn/dave/article/1779 http://www.cndba.cn/dave/article/1779 http://www.cndba.cn/dave/article/1779
http://www.cndba.cn/dave/article/1779
http://www.cndba.cn/dave/article/1779 http://www.cndba.cn/dave/article/1779
http://www.cndba.cn/dave/article/1779
http://www.cndba.cn/dave/article/1779
http://www.cndba.cn/dave/article/1779
http://www.cndba.cn/dave/article/1779

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7968868次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ