Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Cascade delete
On Tue, 08 Dec 1998 17:16:01 -0800, Steven <koh_cc_at_pacific.net.sg>
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
>
You can set it up with foreign key relationship between the two table.
eg.
create table parent(
id number primary key,
data varchar2(200) )
/
create table child(
id number primary key,
pid number,
data varchar2(200),
foreign key ( pid ) references parent(id) on delete cascade )
/
So now when you delete from the parent table, any child records that have a pid matching the id in parent will also be deleted.
hope this helps.
chris.
>
>
> 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
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.
![]() |
![]() |