Azure Lei Zhang的博客

weibo: LeiZhang的微博/QQ: 185165016/QQ群:319036205/邮箱:leizhang1984@outlook.com/TeL:139-161-22926

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

create or replace view view_fk as
select
    a.table_name 外键表,
    c.column_name 外键列,
    b.table_name 主键表,
    d.column_name 主键列,
    decode(a.validated,'VALIDATED',0,1) 多选
from
    user_constraints a,
    user_constraints b,
    user_cons_columns c,
    user_cons_columns d
where
    a.r_constraint_name=b.constraint_name
    and a.constraint_type='R'
    and b.constraint_type='P'
    and a.r_owner=b.owner
    and a.constraint_name=c.constraint_name
    and b.constraint_name=d.constraint_name
    and a.owner=c.owner
    and a.table_name=c.table_name
    and b.owner=d.owner
    and b.table_name=d.table_name

 

 

posted on 2010-07-01 15:19  Lei Zhang的博客  阅读(180)  评论(0编辑  收藏  举报