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 = ‘RAND b.Constraint_Type = ‘PAND 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;

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

上一篇:用PS给3dmax渲染图添加人物和树


下一篇:Java-JDBC防止SQL注入攻击