I essentially have 2 tables, one named empbb02 and another called infobb02. I wa
ID: 3794827 • Letter: I
Question
I essentially have 2 tables, one named empbb02 and another called infobb02.
I want to insert a foreign key into infobb02 and have it make sure it is linked as a parent to empbb02 (since both tables have the same column called: EMPNO).
This is what I tried:
ALTER TABLE empbb02 ADD CONSTRAINT pk_empbb02_empno PRIMARY KEY (EMPNO)
ALTER TABLE infobb02 ADD CONSTRAINT pk_infobb02_empno PRIMARY KEY (EMPNO)
however I receive an error from my live SQL when running it:
ORA-02298: cannot validate (SQL_EOTBMPLTBLKHWFZRYEHITBYIH.) - parent keys not found
Explanation / Answer
When this key is enforced, Oracle checks that all EMPNO values present in "infobb02" table is present in "empbb02" table.
Your options:
Find the offending keys by running
and then insert them into the empbb02 table
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.