Friday, April 26, 2019

ORA-02266: unique/primary keys in table referenced by enabled foreign keys getting while import

Error:
ORA-39120: Table "SCHEMA"."TESTTAB" can't be truncated, data will be skipped. Failing error is:
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
ORA-00955: name is already used by an existing object

Solution:
Step-1: Use below query to disable constraint
select 'alter table '||a.owner||'.'||a.table_name||' disable constraint '||a.constraint_name||';'
from user_constraints a, all_constraints b
where a.constraint_type = 'R'
and a.r_constraint_name = b.constraint_name
and a.r_owner  = b.owner
and b.table_name = 'TESTTAB';

Output:
alter table SCHEMA.TESTTAB disbale constraint TESTTAB_DG_FK1;
alter table SCHEMA.TESTTAB disable constraint TESTTAB_DG_FK2;

Step-2
Then start import job again


No comments:

Post a Comment

How can I restore Cassandra snapshots?