DBAtlas · Database operations atlas

ORA-02291: integrity constraint violated - parent key not found

Oracle

What does it mean?

A foreign key constraint was violated. No parent row was found corresponding to the value inserted into the child table; that is, the referenced record does not exist.

Why does it happen?

An INSERT/UPDATE referencing a nonexistent parent record, the parent table row not inserted yet, the wrong load order (child before parent), or the match failing due to case or whitespace differences.

How to fix it

Insert the relevant record into the parent table first, then into the child table. Verify that the reference exists: SELECT * FROM parent_table WHERE key_col = value; In bulk loads, process tables in the correct order (parent first). To find the violating row, compare the value in the child table with the parent table using NOT IN / an anti-join.

Open in DBAtlas →

More from this engine