I've got a database consisting of four tables. Relation schema as follows in the picture:
And here are the rows:
Now I'm trying to delete the owner with owner id
delete from owners
where ownerid = 'OW1' and petid = 'PT1'
ORA-02292: integrity constraint (TEST_1.ADDRESSES_OWNERS_FK) violated - child record found
Well, if an anonymous block counts as one statement, just wrap your deletes in a block:
begin delete from addresses where ownerid = 'OW1'; delete from contacts where ownerid = 'OW1'; delete from pets where ownerid = 'OW1'; delete from owners where ownerid = 'OW1'; end; /
SQL Fiddle. Seems like a bit of a cheat, but if those are the conditions you've been given...