Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Removing duplicate rows from a table !
Assuming that we have duplicate rows ( NOT duplicate keys ), you may try this. I have borrowed this from a friend of mine.
We have used it successfully. Each of the columns in the table are included as predicates to confirm that we are deleting only the duplicate rows.
delete from noderelatedreplicationqueue a where rowid < (select max(rowid) from noderelatedreplicationqueue b
where a.NODENBR = b.NODENBR and a.LASTUPDATETS = b.LASTUPDATETS and a.NODEABOVENBR = b.NODEABOVENBR and a.TRANSACTIONTYPEIND = b.TRANSACTIONTYPEIND and a.NODETYPECD = b.NODETYPECD and a.NODEABOVETYPECD = b.NODEABOVETYPECD and a.DISTANCENBR = b.DISTANCENBR and a.MARKETCD = b.MARKETCD and a.TOPLEVELIND = b.TOPLEVELIND and a.LOGICALDELETEIND = b.LOGICALDELETEIND and a.LASTUPDATENBR = b.LASTUPDATENBR )
Hope this helps.
Govind
-----Original Message-----
Rama, Shreekantha (K.)
Sent: Thursday, October 16, 2003 3:45 PM
To: Multiple recipients of list ORACLE-L
Hi,
I am trying to remove the duplicate rows from a table with the column data.. I cannot use PK as it's just a sequence number... I could find all the duplicate rows by grouping the column. but how can i delete only the duplicate ones and retain the original data.. Any help is gr8 ! ! !
Warm Regards
Shreekanth
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Rama, Shreekantha (K.)
INET: srama2_at_ford.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------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).
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------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 Oct 16 2003 - 15:09:32 CDT