ORACLE 数据库中查看所有表的外键信息SQL
SELECT a.OWNER "外键拥有者", a.Table_Name "外键表", c.Column_Name "外键列", b.OWNER "主键拥有者", b.Table_Name "主键表", d.Column_Name "主键列", c.Constraint_Name "外键名", d.Constraint_Name "主键名" 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` order by a.Table_Name asc;
学问:纸上得来终觉浅,绝知此事要躬行
为事:工欲善其事,必先利其器。
转载请标注出处!