/* C (check constraint on a table) C 表示 CHECK 约束。
P (primary key) P 表示主键
U (unique key) U 表示唯一
R (referential integrity) P 表示引用(外键)
V (with check option, on a view)
O (with read only, on a view)*/
select b.column_name as pk, b.table_name as ts
from user_cons_columns a, user_cons_columns b, user_constraints c
where c.constraint_type = ‘R‘
and c.constraint_name = a.constraint_name
and R_constraint_name = b.constraint_name
and a.table_name = ‘AC60‘;
select A.*, A.table_name, A.constraint_name, B.column_name
from dba_constraints A, dba_cons_columns B
where A.constraint_name = B.constraint_name
--and A.constraint_type = ‘F‘
and A.table_name = ‘AC60‘
and A.owner = ‘NREI‘;
select A.owner 原表拥有者,
A.table_name 原表,
A.constraint_name 约束名称,
A.constraint_type 约束类型,
B.column_name 原表约束字段,
A.delete_rule 删除级联,
A.R_OWNER 引用表拥有者,
A.R_CONSTRAINT_NAME 引用约束名称,
AA.table_name 引用表,
BB.column_name 引用列
from all_constraints A
inner join all_cons_columns B
on A.constraint_name = B.constraint_name
and A.table_name = B.table_name
left join all_constraints AA
on A.r_constraint_name = AA.constraint_name
left join all_cons_columns BB
on AA.constraint_name = BB.constraint_name
and AA.table_name = BB.table_name
where A. owner = ‘NREI‘
and A.table_name = ‘AC01‘
--and A.CONSTRAINT_TYPE=‘R‘