Oracle中查询该表中的主键被哪些表引用的SQL语句:
select c.TABLE_NAME
from all_constraints p, all_constraints c
where p.table_name = '表名'
and p.OWNER = SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA')
and c.OWNER=SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA')
and c.constraint_type = 'R'
and p.CONSTRAINT_NAME = c.R_CONSTRAINT_NAME
Oracle中查询该表中的外键来源于哪些表的SQL语句:
select cl.table_name
from user_cons_columns cl
left join user_constraints c
on cl.constraint_name = c.r_constraint_name
where c.constraint_type = 'R'
and c.table_name = '表名'