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;