-1

I have a migration script in between 2 different schema database. The script does 3 things:

  1. Disable constraint
  2. Insert record from old schema to new schema
  3. Enable constraint

During enable constraint, it encouter ORA-02298 - Parent keys not found: at the following 2 tables:

ALTER TABLE COUNTRY ENABLE CONSTRAINT COUNTRY_FK1;
ALTER TABLE EMPLOYEE ENABLE CONSTRAINT EMPLOYEE_FK7;

Anything went wrong in the table structure definition of these 2 tables?

APC
  • 144,005
  • 19
  • 170
  • 281
user2102665
  • 429
  • 2
  • 11
  • 26
  • 2
    Possible duplicate of [ORA-02298 Parent Keys Not Found?](https://stackoverflow.com/questions/28732053/ora-02298-parent-keys-not-found) – TZHX Apr 11 '18 at 05:49
  • it's different, this error i hit during enable constraint – user2102665 Apr 11 '18 at 05:51
  • Nothing wrong with *structure definition*, but with data. There are *detail* records that doesn't have matching *master* ones (for example, it says that employee Littlefoot works in department 10, while table DEPARTMENTS doesn't have a row with department = 10). – Littlefoot Apr 11 '18 at 05:51
  • it's not different; when you're enabling the constraint it checks the data conforms to it. that error means that it can't enforce the constraint with the data existing as it does. – TZHX Apr 11 '18 at 05:52
  • 1
    ok, let take table COUNTRY as an example, the FK linked to table REGION.REGION_CODE. So you are saying the same code found in COUNTRY but not in REGION? – user2102665 Apr 11 '18 at 05:59

1 Answers1

0

It appears you are migrating detail records without ensuring that all the foreign key values are present in the referenced tables. If this is the case then you need to migrate records from REGION@SOURCE_DB into REGION@TARGET_DB before you migrate the COUNTRY records.

APC
  • 144,005
  • 19
  • 170
  • 281