// Oracle error reference

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
Error message
integrity constraint (string.string) violated - child record found

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

  1. 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;
  2. If children should go with the parent, recreate the foreign key with ON DELETE CASCADE (or ON DELETE SET NULL).

    ALTER TABLE orders ADD CONSTRAINT orders_customer_fk
        FOREIGN KEY (customer_id) REFERENCES customers (id) ON DELETE CASCADE;

Related errors

More constraints and keys errors

The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.

// fewer errors, faster fixes

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.