DBAtlas · Database operations atlas

ORA-02292: integrity constraint violated - child record found

Oracle

What does it mean?

A parent row was deleted or its key changed, but the foreign key constraint did not allow it because dependent child records exist.

Why does it happen?

Trying to DELETE a parent row that has records in the child table; the FK is defined without ON DELETE CASCADE; dependent records were not cleaned up first.

How to fix it

First delete the dependent child records or move them to another parent record, then delete the parent row. If the business rule allows it, recreate the foreign key with 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; To find dependent rows, query the child table by the parent key.

Open in DBAtlas →

More from this engine