ORA-02292: integrity constraint violated - child record found
A DELETE or key UPDATE on a parent row was blocked because child rows still reference it through a foreign key.
- Error code
ORA-02292- Category
- Constraints and keys
What it means
ORA-02292 is the other side of a foreign key: you tried to delete a parent row, or change its key, while rows in a child table still point at it. The message names the child's foreign key constraint.
Common causes
- Deleting a customer, order or other parent that still has dependent rows.
- Updating a primary key value that child rows use.
- Cleaning up test data in the wrong order.
How to fix it
-
Find the child table and delete or reassign the child rows first.
SELECT owner, table_name FROM all_constraints WHERE constraint_name = 'ORDERS_CUSTOMER_FK'; DELETE FROM orders WHERE customer_id = 42; DELETE FROM customers WHERE id = 42;
-
If children should go with the parent, recreate the foreign key with
ON DELETE CASCADE(orON DELETE SET NULL).ALTER TABLE orders ADD CONSTRAINT orders_customer_fk FOREIGN KEY (customer_id) REFERENCES customers (id) ON DELETE CASCADE;
Related errors
ORA-02291integrity constraint violated - no parent keyORA-02449unique/primary keys referenced by foreign keys1451MySQL: Foreign key fails: cannot delete parent row23503PostgreSQL: foreign key constraint violation547SQL Server: Statement conflicted with a constraint
More constraints and keys errors
ORA-00001unique constraint violatedORA-01400cannot insert NULL into columnORA-02266keys referenced by enabled foreign keys
The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.
Work on Oracle in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Oracle and the other databases you use.