RE: Cleanup of child records...
Title: Cleanup of child records... 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-From: Richard Huntley [mailto:[EMAIL PROTECTED]]Sent: Thursday, June 13, 2002 12:59 PMTo: Multiple recipients of list ORACLE-LSubject: Cleanup of child records... 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.
Re: Cleanup of child records...
alter child table add constraint foreign key ... references ... exceptions into exception_table then delete the rowids in the child table that are in the exception table --- Richard Huntley [EMAIL PROTECTED] wrote: 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. __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Rachel Carmichael INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).
RE: Cleanup of child records...
Title: Message delete from childtable a where not exists (select 1 from parenttable b where b.key1=a.key1 and b.key2=a.key2...) ; try it as - select *from childtable a where not exists (select 1 from parenttable b where b.key1=a.key and b.key2=a.key2...) ; to make sure it is going to delete what you think it is. HTH, Beth -Original Message-From: Richard Huntley [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 12:59 PMTo: Multiple recipients of list ORACLE-LSubject: Cleanup of child records... 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.
RE: Cleanup of child records...
You can Enable Parallel PML and Delete the Records on the child Table that are not there in the Parent Table. You can use the Not Exists instead of the Not In. If you are going to use the In Caluse then ry enabling Parallel Optiuon on the select also ... HTH Best Regards, Ganesh R Tel : +971 (4) 397 3337 Ext 420 Fax : +971 (4) 397 6262 HP : +971 (50) 745 6019 Live to learn... forget... and learn again. -Original Message- Huntley Sent: Thursday, June 13, 2002 8: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: Ganesh Raja INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).