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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Cleanup of child records...

RE: Cleanup of child records...

From: Magaliff, Bill <Bill.Magaliff_at_lendware.com>
Date: Thu, 13 Jun 2002 09:30:10 -0800
Message-ID: <F001.0047D5EA.20020613093010@fatcity.com>


delete from <child_table> where <fk_field> not in
(select <pk_field> from <parent_table>);
 

or  

delete from <child_table> where not exists
(select <pk_field> from <parent_table>

where <parent_table>.<pk_field> = <child_table>.<fk_field>);  

not exists usually out performs not in, but both will work  

bill  

-----Original Message-----
Sent: Thursday, June 13, 2002 12:59 PM
To: Multiple recipients of list ORACLE-L

TIA List,

What is the most efficient way to remove child records from a table that have no parent records in it's parent table. I want to build a FK, to keep this from happening, but I need to do some cleanup first.

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Magaliff, Bill
  INET: Bill.Magaliff_at_lendware.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Thu Jun 13 2002 - 12:30:10 CDT

Original text of this message

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