| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Deleting from a related tables.
In article <3B4B30DB.FCA3CA47_at_attws.com>, "Daniel says...
>
>Jeff Boyer wrote:
>
>> Hey all,
>>
>> This is a very simple question I'm sure............. anyway, can anyone tell
>> me the best way to delete a record that has data in related tables.
>> Basically I need to know if there is a way to cascade a delete when deleting
>> from the top table. I am using Oracle 8i as a backend for my online
>> application. I need to allow the Admin to delete records.......
>>
>> Thanks ,
>> Jeff
>
>You can do it one of two ways: A delete trigger or by passing the parameters to
>a stored procedure and having it perform the checks and multiple deletes.
>
or, since he wants to do it from the "top" table and have it "cascade", he might opt for the easy way:
create table top ( x int primary key );
create table child ( x references top ON DELETE CASCADE );
That would be the best way.
>When doing this ... remember the heirarchy created by any foreign keys. You will
>only be able to delete in a single order unless using deferrable constraints.
>
>Daniel A. Morgan
>
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Tue Jul 10 2001 - 12:37:30 CDT
![]() |
![]() |