ORA-02292: integrity constraint (BLDBANK.F_YXDH) violated - child record found

当尝试删除具有外键约束的Oracle数据库中父表的记录时,可能会遇到ORA-02292错误。此错误表明在子表中存在相关记录。解决这个问题的步骤包括:确定父表和子表,然后先删除子表中的相关记录,最后删除父表中的记录。如果需要,可以暂时禁用约束来完成操作。


删除数据时遇到:

ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录

ORA-02292: integrity constraint (BLDBANK.F_YXDH) violated - child record found

 

关于这个错误,oracle官方解决方法是:
Error: orA-02292: integrity constraint <constraint name> violated - childrecord found

Cause: You tried to Delete a recordfrom a parent table (as referenced by a foreign key), but a record in the childtable exists.

Action: The options to resolve this oracle error are:
This error commonly occurs when you have a parent-child relationshipestablished between two tables through a foreign key. You then have tried todelete a value into the parent table, but the corresponding value exists in thechild table.
To correct this problem, you need to update or delete the value into the childtable first

 

解决步骤

1、  找出父表(需要删除表数据的表)所属用户,然后用此用户登录数据库(若已经使用此用户登录则省略此部)

select*from all_tableswhere table_name=upper('blood_test')     blood_test是父表、要删除数据的表

2、  根据约束名查找子表(引用父表字段作为外键的表)

select*from user_constraintse where e.constraint_name='F_YXDH'   F_YXDH是报错时的约束名

3、  根据条件将子表中的数据删除,然后再删除父表中的记录

 

备注

         altertable 表名 disable constraint 约束名;

altertable 表名 enable constraint 约束名;

可以禁用约束,然后删除数据,但是再重启约束的时候也会有报错,若是删除表的操作可以先禁用约束然后再启用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值