当我们在执行删除记录的时候,会报错外键约束不能删除。
例如:执行delete from task;时报错:
ORA-02292: integrity constraint (TSSH.FK_TASK_TASKID) violated - child record found
如果不了解表之间的关系,可以通过以下语句查询到外键是建在哪张表上的:
select * from dba_constraints where constraint_name='xxx' and constraint_type = 'R';
可以通过执行以下语句查询到外键是建在
select table_name from dba_constraints where constraint_name='FK_TASK_TASKID' and constraint_type = 'R';
查询出在A表上的,先把A表drop掉,就可以删除 task表记录了。

5452

被折叠的 条评论
为什么被折叠?



