Avatar of cofactor
cofactor
 asked on

delete records from table with foreign keys

I have 3 tables .  the tables are connected with Foreign keys

I want to delete some records but as they are interconnected by foreign keys i have to delete all of the dependencies.

I want a query like below but this does not work

delete from tableA , tableB , tableC where tableA.w = tableB.m and tableB.r =tableC.s  AND tableA.y=5


i think this way i can remove the records from the above 3 tables which are connected by foreign keys

but that query is not correct .......can you  make my query correct ?
Oracle Database

Avatar of undefined
Last Comment
cofactor

8/22/2022 - Mon
cofactor

ASKER
here is a  sample image i have drawn to  illustrate what i want

http://docs.google.com/Doc?id=dc83hzcs_347dnht7chd

see the red cuts ....i want to delete those records using my above query.

can you modify my query or tell me suggestions ?
SOLUTION
Sean Stuber

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
sathyagiri

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
crxi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
cofactor

ASKER
As someone pointed , google doc  is blocked . i am  attaching the  sample  image here itself.

Hope , this will be more clear to all of you guys.


as of now , i don't want to change  the existing  table structure ......so writing trigger and foreign key ON DELETE CASCADE is out of reach.

deletion by query is a temporary workaround for me

any more comments please ?

test.png
SOLUTION
Sean Stuber

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
cofactor

ASKER
somehow , i  posted a wrong  replication of my problem .
but anyway,  it was helpful
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck