已知表的主键,如何查看所有引用它为外键的表

解决方案 »

  1.   

    查询主外键关系语句
    http://space6212.itpub.net/post/12157/107584
      

  2.   

    Select b.table_name 主键表名,
               b.column_name 主键列名,
               a.table_name 外键表名,
               a.column_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 网上多了去了,再贴上面这个
      

  3.   

    select * from user_constraints t where t.constraint_type='R' and t.r_constraint_name='PK_NAME'这里就有。