/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

ORACLE 数据库中查看所有表的外键信息SQL

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;
posted @ 2021-01-29 09:32  一品堂.技术学习笔记  阅读(875)  评论(0编辑  收藏  举报