当前位置:数据库 > Oracle >>

oracle查找外键表

oracle查找外键表
 
Sql代码  
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  
and b.table_name = 'JDT_DEPARTMENT'  

 


CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,