FAQ
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).

Search Discussions

  • Todd Boss at Oct 16, 2003 at 8:04 pm
    We just discussed this about a month ago.

    3 basic solutions:

    delete from table where rowid not in
    (select max(rowid) from table group by col_1,col_2,etc);
    sql only solution, not really feasible in huge environments

    Alter table mytab enable constraint PK exceptions into exceptions;
    Better way; much faster for large tables, lets you audit the
    duplicate rows by examining exceptions table.

    Write a cursor; sql coding solution ... probably doesn't
    give you anything mroe than what option 2 provides.

    boss
    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).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.net
    --
    Author: Todd Boss
    INET: boss_at_i-sphere.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).
  • Govind.Arumugam_at_alltel.com at Oct 16, 2003 at 8:09 pm
    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).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.net
    --
    Author:
    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).

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouporacle-l @
categoriesoracle
postedOct 16, '03 at 7:44p
activeOct 16, '03 at 8:09p
posts3
users3
websiteoracle.com

People

Translate

site design / logo © 2023 Grokbase