Skip to main content

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 :) 




Comments

Popular posts from this blog

DBA_SCHEDULER_JOB_RUN_DETAILS and PURGE_LOG

How to purge DBA_SCHEDULER_JOB_RUN_DETAILS? Manually deleting from DBA_SCHEDULER_JOB_RUN_DETAILS is not recommended by oracle.DBA_SCHEDULER_JOB_RUN_DETAILS is a view that is using two master tables (scheduler$_job_run_details and scheduler$_event_log) and display the information about jobs history. As there is one procedure named PURGE_LOG and Oracle have Scheduler for this procedure. It will purges all rows in the job log that are older than 30 days.This is the default behavior of this procedure. You can change this to any number of days you want by setting the attribute "SET_SCHEDULER_ATTRIBUTE". e.g. exec DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE('log_history','15'); It will purge all logs older than 15days and it will maintain the history of 15days. But If you want manually purge these logs, you can use below solution:- exec DBMS_SCHEDULER.PURGE_LOG(log_history => 15, which_log => 'JOB_LOG'); It will purge all entries from the jog log that are o...

ORA-65016: FILE_NAME_CONVERT must be specified

ORA-65016: FILE_NAME_CONVERT must be specified I just started working on 12C version of oracle database.It's new to me and facing many problems. Error code: ORA-65016: FILE_NAME_CONVERT must be specified Description:"ORA-65016: FILE_NAME_CONVERT must be specified" normally occurs when you create a PDB.I will explain later what is a PDB. Cause and solution :  ORA-65016: FILE_NAME_CONVERT must be specified caused when Data files, and possibly other files, needed to be copied as a part of creating a pluggable database.Enable OMF or define PDB_FILE_NAME_CONVERT system parameter before issuing CREATE PLUGGABLE DATABASE statement, or specify FILE_NAME_CONVERT clause as a part of the statement and make sure the path you are giving to convert the file exists. I think if you are creating the PDB's using GUI then you will not face this error "ORA-65016: FILE_NAME_CONVERT must be specified". If you creating ODB using script and you have gave a wrong path then may you f...

ORA-02051 Another Session Or Branch In Same Transaction Failed

ORA-02051 Another Session Or Branch In Same Transaction Failed (Doc ID 2253226.1)          SYMPTOMS for ORA-02051 Another Session Or Branch In Same Transaction Failed. Database performance is slow and caused   the transactions ORA-02051 another session or branch in same transaction failed or finalized CAUSE for ORA-02051 Another Session Or Branch In Same Transaction Failed. Session transactions branches caused the issue Excessive Waits On The Event "Global transaction acquire instance locks" SOLUTION Please use below sql and identified underscore parameter values for ORA-02051 Another Session Or Branch In Same Transaction Failed : SQL> select a.ksppinm "Parameter", b.ksppstvl "Session Value",c.ksppstvl "Instance Value"  FROM x$ksppi a,x$ksppcv b, x$ksppsv c  WHERE a.indx = b.indx AND a.indx = c.indx AND a.ksppinm LIKE '/_%' escape '/'  AND (a.ksppinm like '%clusterwide_global%' or a.ksppinm like '%disable_autotune_...