Re: Cascade delete
Date: Tue, 08 Dec 1998 12:55:20 -0800
Message-ID: <366D9238.BA4D81CE_at_pnl.gov>
The key is how you set define the Child Foriegn Key constraint
Create Table A
(A_Id Integer);
Alter Table A
Add Constraint PK_A
Primary Key (A_Id);
Create Table B
(B_Id Integer,
A_Id Integer );
Alter Table B
Add Constraint FK_B
Foreign Key (A_Id)
References A On Delete Cascade;
After this is done, delete from a where a_id=1 will delete everything in b with an a_id of 1.
Good Luck,
Meryl Birn
Pacific Northwest National Laboratory
Steven wrote:
> hi,
>
> Can anyone advise on how to delete the master and detail table using
>
> "Cascade" SQL command.
>
> Table a : Parent table
> Table b : Child table
>
> l've tried : delete from a where a_id=1 cascade.
>
> --
> With regards
> Steven
>
> Steven Koh, Internet Software Engineer,
> www.mediaworks.com.sg, www.pacific.net.sg
Received on Tue Dec 08 1998 - 21:55:20 CET