This content has been marked as final. Show 7 replies
927851 wrote:you can not delete parent when child still exists.
Am using two tables called e1 and e2. In e2 table is having foriegn key which is reffering foriegn key of table e2. am deleting the records in parent table i got the below exception.
Please help me.
I got this exception
delete from e1where id=3005
ERROR at line 1:
ORA-02292: integrity constraint (e2.fkk_FK2) violated - child record
how to delete the parent table value without deleting the child value
read the manuals or some book, here's an e.g. for you.
create table e1(id number not null) create unique index idx_e1 on e1(id) alter table e1 add constraint pk_e1 primary key(id) create table e2(id_e2 number,id_e1 number) alter table e2 add constraint fk_e2 foreign key(id_e1) references e1(id) on delete cascade insert into e1 values(1) insert into e2 values(1,1) insert into e2 values(2,1) insert into e2 values(3,1) commit; delete from e1 where id=1