20.5.17

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

“Error: ORA-02291: integrity constraint violated - parent key not found”



Reason:   A Primary key does not have the same value as the foreign key. We will discuss it in detail later in this article.

Action:   For ORA-02291: integrity constraint violated - parent key not found You may either delete the foreign key or the matching primary key can be added. In either way, you may try to get this error corrected.


Let's understand more about ORA-02291: integrity constraint violated - parent key not found?


The Oracle software brought us the strength by which multiple tables in the database can pass on information so efficiently. Not only this, there are numerous devices in this software which enables access to and sourcing data from multiple tables. You can easily execute complicated database issues without an unusual uncertainty by creating statements with the fantastic characteristic of this software. Realistically, if we talk about user or database no one is perfect or 100% error-free or have the sense to identify forthcoming possible errors occurs throughout the regular activities.


The most well-known error occurs while manipulating data across multiple data tables is the ORA-02291.Now, we will have a brief discussion about ORA-02291: integrity constraint violated - parent key not found:-

" integrity constraint <constraint name> violated – parent key not found” is the standard message co-occurred with the ORA-02291.Which means someone used the primary key in order to execute a reference to a specific table but somehow, during this process specified column failed to match the primary key. As well as, the other reason for executing the error can be non-existence of primary key for the table in question.It is useful to secure a note of few important things related to the primary key before we proceed further.




In oracle, a primary key is a single field or combination of fields that defines a record in a unique way. Every field of the primary key must contain some value, it means, the value of any field can never be null and each table contains only one primary key. One last important thing about a primary key that it cannot hold more than thirty-two columns.


Now while we are familiar with all concepts of a primary key, it will not be difficult for us to determine the error and fix it with fewer efforts (ORA-02291: integrity constraint violated - parent key not found). 

Usually, the error occurs when foreign key plays a parent-child relation between two tables. The process of foreign key states that each table shares the same value. overall, the referenced table is a parent table. On the other hand, the child table will take place where foreign key originates from. It is quite often that a foreign key in a child table will reference to a primary key in a parent table. The cause why the ORA-02291 trigger is when the corresponding parent is empty (does not have any value) and by the time, you still try to insert a value into a child table which includes a foreign key. Your this action disrupts the integrity of referential relationship, bother standard functionality and provoking oracle to produce an error message "ORA-02291: integrity constraint violated - parent key not found".



“The valid method to fix the error ORA-02291: integrity constraint violated - parent key not found “--- the primary table to insert the value will be the parent and obviously secondary table to insert value will be the child table. To elaborate, you should insert the value inside the parent table first and later, add it to the child table.



keep sharing :)