ORA-02292: integrity constraint violated - child record found(违反完整约束条件 - 已找到子记录)
Oracle含义
删除了父行或修改了其键,但由于存在依赖的子记录,外键约束不允许该操作。
原因
尝试 DELETE 在子表中有记录的父行;FK 定义时没有 ON DELETE CASCADE;未事先清理依赖记录。
解决方法
先删除依赖的子记录或将其移到另一条父记录下,然后再删除父行。如果业务规则允许,用 ON DELETE CASCADE 重新创建外键:ALTER TABLE child DROP CONSTRAINT fk_name; ALTER TABLE child ADD CONSTRAINT fk_name FOREIGN KEY (my_column) REFERENCES parent(key_col) ON DELETE CASCADE; 要查找依赖行,按父键查询子表。
同一数据库的其他条目
- ORA-01438value larger than specified precision allowed for this column(值大于此列允许的指定精度)
- ORA-01400cannot insert NULL into (column)(无法将 NULL 插入(列))
- ORA-02291integrity constraint violated - parent key not found(违反完整约束条件 - 未找到父项关键字)
- ORA-00979not a GROUP BY expression(不是 GROUP BY 表达式)
- ORA-00918column ambiguously defined(列定义不明确)
- ORA-06550line/column PLS-... PL/SQL compilation error(行/列 PLS-... PL/SQL 编译错误)
- ORA-04068existing state of packages has been discarded(已丢弃程序包的当前状态)