We have taken a export of few tables and imported it in a other database. Before the import we disabled all the constraints truncated the table and imported the data which went fine and after that when we are enabling the constraints one of the foreign key constraints is not getting enabled giving the below error.
ORA-02298: cannot validate (PRDPUB.IX_FK_PGPLAN_SOURCEKEY_PLAN) - parent keys
not found
Also we tried the 2nd option where we initiated importing the data when the foreign key constraints was already in enable state but here also the import is failing with below error.
ORA-31693: Table data object "PRDPUB"."BP_REX_CONT" failed to load/unload and is being skipped due to error:
ORA-02291: integrity constraint (PRDPUB.IX_FK_PGPLAN_SOURCEKEY_PLAN) violated - parent key not found
Job "SYSTEM"."SYS_IMPORT_TABLE_05" completed with 1 error(s) at 07:59:18
I got one oracle note "DataPump Import Fails With Errors ORA-31693 ORA-2291 ( Doc ID 1062564.1 )" similar to our issue. Which given the below to suggestion
<Moderator Edit - deleted contents of MOS Doc - pl do not post such content - it is a violation of your Support agreement>
But in our case we can't implement this as the foreign key is referring to the primary key column of the same table.
ALTER TABLE "PRDPUB"."BP_REX_CONT" ADD CONSTRAINT "IX_FK_PGPLAN_SOURCEKEY_PLAN" FOREIGN KEY ("DBPARENTPGSOURCEKEY") REFERENCES "PRDPUB"."BP_REX_CONT"("DBKEY") ENABLE;