查询外键字段信息
set pagesize 1000
col 外键拥有者 for a20
col 外键表 for a30
col 外键列 for a20
col 主键拥有者 for a20
col 主键表 for a30
col 主键列 for a20
col 外键名 for a30
col 主键名 for a30
select a.owner 外键拥有者,
a.table_name 外键表,
c.column_name 外键列,
b.owner 主键拥有者,
b.table_name 主键表,
d.column_name 主键列,
c.constraint_name 外键名,
d.constraint_name 主键名
from dba_constraints a,
dba_constraints b,
dba_cons_columns c, –外键表
dba_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
and b.owner in (‘ownername’);