最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

查询外键。

IT圈 admin 2浏览 0评论

查询外键。

Select b.table_name 主键表名,
           b.column_name 主键列名,
           a.table_name 外键表名,
           a.column_name 外键列名,
           a.constraint_name 外键名
From (Select a.constraint_name,
                       b.table_name,
                       b.column_name,
                       a.r_constraint_name
          From user_constraints a, user_cons_columns b
         Where a.constraint_type = 'R'
           And a.constraint_name = b.constraint_name) a,
       (Select Distinct a.r_constraint_name, b.table_name, b.column_name
          From user_constraints a, user_cons_columns b
         Where a.constraint_type = 'R'
           And a.r_constraint_name = b.constraint_name) b
Where a.r_constraint_name = b.r_constraint_name

查询外键。

Select b.table_name 主键表名,
           b.column_name 主键列名,
           a.table_name 外键表名,
           a.column_name 外键列名,
           a.constraint_name 外键名
From (Select a.constraint_name,
                       b.table_name,
                       b.column_name,
                       a.r_constraint_name
          From user_constraints a, user_cons_columns b
         Where a.constraint_type = 'R'
           And a.constraint_name = b.constraint_name) a,
       (Select Distinct a.r_constraint_name, b.table_name, b.column_name
          From user_constraints a, user_cons_columns b
         Where a.constraint_type = 'R'
           And a.r_constraint_name = b.constraint_name) b
Where a.r_constraint_name = b.r_constraint_name

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论