首页  :: 新随笔  :: 管理

记录在表:user_constraints 

 

 select a.owner, --主键拥有者  
        a.table_name, --主键表  
        b.column_name, --主键列  
        c.OWNER, --外键拥有者  
        c.table_name, --外键表  
        d.column_name --外键列  
 from user_constraints  a  
 
left join user_cons_columns b   
             
on  a.constraint_name=b.constraint_name  
 
left join user_constraints c   
             
on c.R_CONSTRAINT_NAME=a.constraint_name  
 
left join user_cons_columns d  
             
on c.constraint_name=d.constraint_name  
 
where  a.constraint_type='P'  
     
and  a.table_name='xxx' --需要查看主外键关系的表  
 order by a.table_name 

 

智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |