Home:ALL Converter>oracle: deferring Foreign Key checks not working

oracle: deferring Foreign Key checks not working

Ask Time:2020-02-19T09:28:42         Author:eastwater

Json Formatter

oracle: deferring Foreign Key checks not working. e.g.,

create table Foo (id number(20,0), name varchar(20), 
    primary key(id));
create table Bar (id number(20,0), name varchar(20), 
    primary key(id),
    constraint FK1 foreign key (id) references Foo (id));

insert into Foo(id,name) values(1, 'foo');
insert into Bar(id,name) values(1, 'bar');

delete data:

SET CONSTRAINTS ALL DEFERRED;

delete from Foo;
delete from Bar;

SET CONSTRAINTS ALL IMMEDIATE;

ERROR:

ORA-02292: integrity constraint violated - child record found

Author:eastwater,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60291745/oracle-deferring-foreign-key-checks-not-working
yy