OracleORA-02291
ORA-02291: Integrity Constraint Violated — Parent Key Not Found
ORA-02291 is the Oracle foreign key constraint error raised when a child record references a parent key value that does not exist in the parent table.
Example Query
INSERT INTO orders (order_id, customer_id) VALUES (1, 9999); -- No customer with id 9999 exists
Common Causes
- 1Parent record not yet inserted when child record is created
- 2Wrong foreign key value due to a data mapping error
- 3Parent record deleted without cascading to child records
How to Fix It
Insert parent records before child records. Verify the parent key exists: SELECT * FROM customers WHERE customer_id = 9999. Define ON DELETE CASCADE if child records should be removed with the parent.
Need a reliable database?
Try Supabase — free PostgreSQL with a generous free tier. No credit card required.
Got a query causing this error?
Paste it into SQLbuddy and get an instant plain-English explanation with optimization tips.
Analyze My Query →