ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
来源:互联网 发布:国培网络研修成果 编辑:程序博客网 时间:2024/06/10 05:01
今天在删除一个表某条记录时,出现如下错误:
ORA-02292: integrity constraint (CICRO.FK8A82499F4C67C41) violated - child record found
于是查看了相关的主键和约束关系,发现了一些问题。
关于这个错误,oracle官方解决方法是:
Error: orA-02292: integrity constraint <constraint name> violated - child record found
Cause: You tried to Delete a record from a parent table (as referenced by a foreign key), but a record in the child table exists.
Action: The options to resolve this oracle error are:
This error commonly occurs when you ha a parent-child relationship established between two tables through a foreign key. You then have tried to delete a value into the parent table, but the corresponding value exists in the child table.
To correct this problem, you need to update or delete the value into the child table first an
总结一语句话,就是:
不能删除包含主键的行,该主键被用做另一个表的外键。
举个例子如下:
首先创建两个表
Create TABLE supplier
( supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
contact_name varchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);
Create TABLE products
( product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier (supplier_id)
);
接着向两个表写入数据
Insert INTO supplier
(supplier_id, supplier_name, contact_name)
VALUES (1000, 'Microsoft', 'Bill Gates');
Insert INTO products
(product_id, supplier_id)
VALUES (50000, 1000);
尝试删除某条记录:
Delete from supplier
Where supplier_id = 1000;
无法删除,报错:
You would receive the following error message:
ORA-02292: integrity constraint (CICRO.FK8A82499F4C67C41) violated - child record found
尝试下面方法,即可解决:
Delete from products
Where supplier_id = 1000;
Then you can delete from the supplier table:
Delete from supplier
Where supplier_id = 1000;
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- ORA-02292: 违反完整约束条件 (用户名.约束名)
- 手动批量处理 “ORA-02292: 违反完整约束条件 - 已找到子记录”
- Oracle ORA-02292: 违反完整约束条件 (UNITELE.TA_SUB_REFERENCE3) - 已找到子记录
- Oracle报错:“ORA-02292:违反完整约束条件(XXX.FKXXX)- 已找到子记录
- Oracle报错:“ORA-02292:违反完整约束条件(XXX.FKXXX)- 已找到子记录
- 有关ORA-02292:违反完整约束条件(XXX.FKXXX)- 已找到子记录的删除方法
- ORA-02292: 违反完整约束条件
- ORA-02292: 违反完整约束条件 (MIDBJDEV2.SYS_C0020757)
- ORA-02291: 违反完整约束条件 (*) - 未找到父项关键字
- ORA-02291: 违反完整约束条件 - 未找到父项关键字
- ORA-02291: 违反完整约束条件 (*) - 未找到父项关键字
- 邻众沾伤车柿耙缆彼焚孜平炊煤日
- 用于考核、评价的投票打分系统解决方案
- c++ 枚举类型
- svn服务器端设置 --- 创建新项目代码仓库
- 随机数函数srand和rand()的使用心得
- ORA-02292: 违反完整约束条件 (用户名.约束名) - 已找到子记录
- Myeclipse报错:Could not open the editor: Invalid thread access
- oracle 得到本周的数据
- cp: omitting directory `XXX'
- Android打开现有工程
- 截取当前屏幕图像,并将图片存入沙盒中。
- VC++中如何复制对话框资源
- UVa 10945 - Mother bear
- hdu 3037 Saving Beans(组合数学)