Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Cascade delete

Re: Cascade delete

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Tue, 08 Dec 1998 16:35:46 GMT
Message-ID: <366f52c0.11507226@inet16.us.oracle.com>


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.



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue Dec 08 1998 - 10:35:46 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US