问题:需要删除一个主表的数据,但是该表被其他表外键关联了,于是需要找到关联的那个表。
解决方法:
通过以下语句查询到外键是建在哪张表上的:
select * from dba_constraints where constraint_name='xxx' and constraint_type = 'R';
例如:
执行delete from student;时报错:
ORA-02292: integrity constraint (CCSYS.FK_STUDENTRUNRESULT_TASKID) violated - child record found
可以通过执行
select table_name from dba_constraints where constraint_name='FK_STUDENTRUNRESULT_TASKID' and constraint_type = 'R';
查询出外键是建在哪张表上的,先把该表删除,就可以删除 student表记录了。