MySQL duplicate entry deletion in 5.5.9

Hey all,
I've noticed that in the newest MySQL, I can no longer do:
ALTER TABLE test ADD UNIQUE INDEX unique_index (id);
ALTER TABLE test DROP INDEX unique_index;
to remove duplicates. I get the following error:
ERROR 1062 (23000): Duplicate entry '3' for key 'unique_index']
This worked fine before the major SQL upgrade. It also works fine on version 5.1.52 on my web host.  I searched through the 5.5.9 release notes and I didn't see anything that should have changed this, but I'm no MySQL guru! Is this a feature or a bug? Any alternate suggestions for deleting duplicates that will work on this version and older versions of MySQL?
Thanks!
Scott
Edit: Just for clarity, the table I'm working on has a single primary key column (UNIQUE_KEY) (with 80+ other data columns) and I'm only detecting the duplicate row based on the value of the primary key column.
Last edited by firecat53 (2011-02-25 03:33:30)

Alright, since I was apparently sucked in by this particular method the first time I googled the answer, care to enlighten me on the 'more practical' non-joke methods, as there appears to be more than one option.
Also, why is that a joke of a feature? Like I said, I'm no MySQL guru so I'm ready to learn!
Thanks,
Scott
edit: is this a 'more practical' method? It's hard when you're learning on your own to sort out the good from the bad sometimes
edit2: using the above method with this table:
+------+------+-------+
| id | data | data1 |
+------+------+-------+
| 1 | 10 | 100 |
| 2 | 100 | 1000 |
| 3 | 1000 | 500 |
| 3 | 1000 | 500 |
+------+------+-------+
and this query:
delete test from test left outer join (select min(id) as RowID, id from test group by id) as KeepRows on test.id=KeepRows.RowID where KeepRows.RowID is null;
I can't quite get it to work...it doesn't delete any rows. What am I missing there?
edit3: This method works -- is it a 'good' method or should I be looking at something different? Again, I'm just matching on duplicates in the primary key column (before the primary key is assigned):
create table test1 like test;
insert into test1 select * from test group by id;
drop table test;
rename table test1 to test;
Last edited by firecat53 (2011-02-25 03:55:10)

Similar Messages

  • Deleting duplicate entries in iCal?

    How do I delete duplicate entries in iCal (identical entries on the same date)?

    Todd,
    I suspected a more serious problem because the answer was too easy.
    Thousands of duplicate entries...Is this what happened?
    According to, Mac OS X 10.4: Stay away from the SyncServices folder: As if it were a swarm of bees, you should stay away from the SyncServices folder in Mac OS X 10.4. Removing or modifying anything in it—or in subfolders within it—may cause unexpected issues. (This folder is located in your Application Support folder, in your Library folder, in your Home folder.)
    Deleting or modifying things in the SyncServices folder may cause unexpected results such as:
    • Duplicate contacts in Address Book or appointments in iCal.
    • Data loss in Address Book or iCal.
    Important: Any lost or duplicate data could propagate to other devices and computers via iSync and .Mac sync. This means data could be lost on other computers.If that is your problem, I suspect that without a backup, duplicate entry deletion will at best be tedious, and at worst fraught with frustration. You may be better off starting from scratch.
    ;~)

  • How to delete duplicate entries in table for the object DNL_CUST_BASIS2

    Hi All,
    I am trying to download the object DNL_CUST_BASIS2.
    In the SMQ2 the status is SYSFAIL.
    I checked in the ST22 for dumps.It says about the error while accessing the table T006.
    While analysing this,i found some duplicate entries in the related tables of this object.
    Can somebody help me how to delete these duplicate entries?
    Thanks,
    Senthil.

    Delete them directly from the table using se16:
    select the entries in the classic view (not ALV or grid view).
    activate the debugger.
    press the view button. --> you'll enter in the debugger
    press F7
    locate the sy-ucomm variable & change it to "DELE".
    press F8
    delete the entries.
    Trick-shots
    but it works!
    Michael.

  • Abap Code to Delete the Duplicate Entries in Datasource

    hI Friends I have a code that I am writing to delete the duplicate entries from CRM Custom Datasource  but it is throwing me error that INVERNO The specified type has no structure and therefore no component called INVERNO Should i define the structure please correct my code below so that it will work to delete the duplicate entries          
    Please help
    Data: l_s_ZOXD530051 like ZOXD530051. ***Extract Structure of Data source
    Case i_DATASOURCE.
    when 'ZZ_DS_CUSTOM_CRM_VALUES'.
    Sort C_T_DATA by INVERNO ZMKT_TYP.
    *write this Statement.
    DELETE ADJACENT DUPLICATES FROM C_T_DATA COMPARING INVERNO ZMKT_TYP.
    endcase.
    Thanks
    Soniya
    null

    Hi
    It means there's no field called INVERNO:
    Data: l_s_ZOXD530051 like ZOXD530051. ***Extract Structure of Data source
    Case i_DATASOURCE.
    when 'ZZ_DS_CUSTOM_CRM_VALUES'.
    <b>*Sort C_T_DATA by INVERNO ZMKT_TYP. <------</b>
    Sort C_T_DATA by INTRENO ZINS_TYP.
    *write this Statement.
    DELETE ADJACENT DUPLICATES FROM C_T_DATA COMPARING INTRENO ZINS_TYP.
    endcase.
    Max

  • How to delete duplicate entries in address book

    Is there an easy way to delete duplicate entries in Address Book?

    I have an iPhone where I create new contact details and a MB Air running OX X 10.7.3
    In Address Book I see duplicate entries across the whole book. The other day I was traveling without my MB and needed to urgently reach someone who's number I knew was in my iPhone contact list for sure but searched and search and couldn't find it.
    Turns out that when I had been going through the Adress Book on the MB Air trying to eliminate some of the duplicates I had chosed --without even knowing it or realzing it-- the card that I guess sync with my iPhone. It was gone. Sure enough, when I got back and looked it up on the MB Air it was still there not syncing to my iPhone.
    I have used Address Book / Card / Look for Duplicates ...
    I have also followed the Help suggesting and pressed Control / select to highlight two duplicate cards and even though the First / Last / Company / phone numbers / etc. are all the same I get the message: "The cards could not be merged because they came from different accounts."
    I have checked with guys from the office who have the exact same problem with no idea how to solve the problem.
    Is it that in order to use Address Book on both an iPhone and an OS X machine you've just got to be smarter, more sophisticated, more IT oriented?
    Seems like a pretty easy thing not to be struggling with.
    I should mention that I was a Mobile Me subscriber and now use iCloud which I'm sure has something to do with all of this.
    But it seems pretty basic to me. If I have an Address Book it should synchronize between OX X and IOS.

  • How to delete duplicate entries in match code

    I want to delete duplicate entries in match code.

    If you go down the search exit route, using function module F4_IF_SHLP_EXAMPLE or function module F4_IF_SHLP_EXIT as a template you want it where callcontrol-step = 'DISP'.  You would sort the table: SORT RECORD_TAB BY STRING and then delete adjacent duplicates. If this does not wok because of the fields you have in your search help, you will need to select the data into another internal table and match the relevant entries from your internal table  with the relevant position in field STRING of RECORD_TAB.  The positions in STRING will be as per the order of the parameters  you have defined in the search help.
    Hope this helps.
    Regards
    Larissa

  • Deleting Duplicate Entries in sender JDBC adapter

    Hi i am working on JDBC to IDOC scenario.
    When i am fetching the records from the Oracle database table using select query, i am getting the records but its getting duplicated many a times and hence its failing at an idoc processing at ECC side..
    Could someone help me in deleting the Duplicate entries and passing only the required entries from Oracle databse to IDOC.
    Here is my select query.:
    Select a.order_num, a.sap_delivery_number, a.sap_delivery_line_number, a.warehouse, a.product, a.product_size, a.order_qty, a.ship_qty from XXX_h a,tr_log t where a.Prod_id = 101..
    Appreciate your help.
    Regards

    >> Its not picking up the old data instead, it is repeating the same set of data multiple times.
    The below suggestion might be helpful
    a) First do your select statement
    b) Second , Use update statement and here set some flag in that table that these records are already queried.  say boolean read = true for the above queried records.
    That's it. When you query next time, you will not reread the same data. You will read the new data.
    Duplicate Entries:  Check with db client tool like Toad or sqlplus and see whether duplicate entries exists in the table. If so, then fix the data first.
    Edited by: Baskar Gopal on Feb 22, 2011 1:02 PM

  • Deleting Duplicate entries from Internal tbale

    Hi All,
    I have used this code to delete duplicate entries from an internal table.
      DELETE ADJACENT DUPLICATES FROM IT_KOSTL COMPARING KOSTL hours.
    After this statment, still the internal table will remain with a duplicate row.
    Earlier table content before the delete statement:
    Lno  KOSTL                PRCTR                       hours                      hours1 
    1    2081010205     0000208101                 5525.000          1574.500
    2    2081010105     0000208101       105162.000     73854.750
    3    2081010105     0000208101       105162.000     73854.750
    4    2081010205     0000208101        5525.000     1574.500
    The Table gets modified after execution of DELETE statement as follows.
    Lno  KOSTL                PRCTR                       hours                      hours1 
    1    2081010205     0000208101                 5525.000          1574.500
    2    2081010105     0000208101       105162.000     73854.750
    3    2081010205     0000208101        5525.000     1574.500
    Why the line 3 is still present in the table?
    I hope as per that syntax, this line too should get delete.... Is it right?
    Basically i would like to delete both line 3 and line 4 from....
    How to resolve this issue?
    Please help me out....
    Regards
    Pavan
    What might be the reason?

    >
    Pavan Sanganal wrote:
    >   DELETE ADJACENT DUPLICATES FROM IT_KOSTL COMPARING KOSTL hours.
    > Why the line 3 is still present in the table?
    >
    > I hope as per that syntax, this line too should get delete.... Is it right?
    >
    Let me answer you all doubts.
    Why the line 3 is still present in the table?
    Actually it's not 3rd line, it's 2nd line.3rd line were deleted.
    when delete adjecent duplicates trigger than it would delete lower line(3rd in your case) not upper line.
    I hope as per that syntax, this line too should get delete.... Is it right?
    NO.

  • Deleting duplicate entries

    I have two tables (Accounts, and Accounts_LOAD). The _Load table is a daily feed.
    For my first step, I need to delete all the duplicates from _Load that exist in Accounts. 
    How can I delete duplicate entries which exist in two tables..?

    I think that the Merge will suffice. My apologies.
    But, now (again, sorry) I have a couple questions on the merge.
    Below is similar to what I would use and a few Q's on it....
    line4: can u use multiple "on" ?
    line5:For 'when matched' i only want to update fields from "_load" to "Accounts" that need to be updated. If they are the same, they would be ignored... is that possible...?
    1 MERGE INTO accounts acc
    2 USING (SELECT **ALLFIELDS**
    3 WHERE SOMESTUFF=STUFFS) STF
    4 ON (ACC.ID_USER = STF.ID_USER) AND (ACC.SYSTEM_ID = STF.SYSTEM_ID)
    5 WHEN MATCHED THEN UPDATE SET acc.bonus = D.bonus + S.salary*.01
    6 DELETE WHERE (S.salary > 8000)
    7 WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
    8 VALUES (S.employee_id, S.salary*0.1)
    9 WHERE (S.salary <= 8000);

  • Delete Duplicate entries in itab

    Dear Experts,
    My code is Below. my requirement is all the work area fields are modify comparing matnr.
    but i am use append duplicates entris allowed.only possible to modify.
    loop at it_ekpo into wa_ekpo.
    read table it_ekpo3 into wa_ekpo3 with key matnr = wa_ekpo-matnr.
    if sy-subrc = 0.
    wa_ekpo-matnr = wa_ekpo3-matnr.
    wa_ekpo-menge = wa_ekpo3-menge.---->count field
    modify it_ekpo from wa_ekpo.
    endif.
    endloop.
    sort it_ekpo.
    DELETE adjacent DUPLICATES FROM it_ekpo comparing matnr.
    (Duplicates entry is not working) so modify is changed.
    reference:   -
    >it_ekpo  in this way
    ebeln      matnr   menge    ecp
    10           lo45       1          iiii
    10           l045       1          uuy
    10           lo77       1          hhj
    13           li12.       1          jhjh     [mainly i join one itab ibn it_ekpo]
    reference------>it_ekpo3.
    ebeln      matnr     menge
    10           lo45        2
    10           lo77        1
    13           li12         1
    my final output is --->it_ekpo          in this way.
    ebeln      matnr   menge    ecp
    10           lo45       2          iiii
    10           lo77       1          hhj
    13           li12.       1          jhjh      
    <removed_by_moderator>
    regards,
    raj.
    Edited by: Julius Bussche on Dec 11, 2008 5:30 PM

    sort it_ekpo by matnr.
    not
    sort it_ekpo.

  • Duplicate entry is not deleted from the TCA tables

    Hi
    We are using Oracle Customer Online to find the duplicate data and Oracle Data Librarian to remove the duplicacy. The request to remove the duplicates is taken up by ODL and the task is performed. When checked from OCO it shows that the duplicate entry has been erased but when checked in the TCA table HZ_PARITES, the entry is still there. Can anyone please help regarding this as why this is so... after removing the duplicate entry why is it still there in the table or if the entry is still there then why cant you access it through OCO
    Regards
    Sourav Biswas

    Hi,
    Did you check the value for "STATUS" column in HZ_PARTIES table for the deleted records? It must be "D" which reperesents "Deleted". See the "REGISTRY_STATUS" AR lookup which validates the Party Statuses.
    When duplicates are eliminated using Data Librarian/Party Merge, the records are not actually deleted from the database, instead the party status will be changed to "D". This must be the reason for not being able to see the records from Customers Online.
    I guess, the same case might have occurred to your entries.
    Wishes,
    RK Goud

  • Duplicate entries in Infotype 0000 :- Delete problem

    Hi,
    There is a scenario where duplicate entries have been entered by mistake in infotype 0000 for a same action XE with same dates.
    If I am trying to delete one of them it's giving me an error "Action XE that changed the status was found . Data
    Inconsistency".
    Please let me know how can I delete one of them manually.
    I can do it through a program by direct table delete but don't want to do that.
    Thanks
    Umang

    don't know if this would work.. but you can give it a try.. ensure nobodyelse is in PA30.. change the time constraint for 0000.. delete the unwanted record & change the Time Constraint back..
    Regards,
    Suresh Datti

  • Delete duplicate entries

    Please go to the following website:-
    http://help.sap.com/saphelp_nw04/helpdata/en/06/aafd54fc4011d195280000e8353423/content.htm
    and please scroll down to find:-
    <b>Deleting Adjacent Duplicate Entries</b>
    To delete adjacent duplicate entries use the following statement:
    DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
                                      [COMPARING <f1> <f 2> ...
                                                 |ALL FIELDS].
    Then  please go to the last example  where the code is written as :-
    DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.
    IS  THIS CORRECT ?
    Regards
    abaper.learner

    Hi learner,
    <b>Deleting a sequence of lines</b>
    DO 101 TIMES.
    DELETE TAB_DEST INDEX 450.
    ENDDO.
    DELETE TAB_DEST FROM 450 TO 550.
    <b>Deleting a set of lines</b>
    LOOP AT TAB_DEST
      WHERE K = KVAL.
    DELETE TAB_DEST.
    ENDLOOP
    DELETE TAB_DEST WHERE K = KVAL.
    <b>DELETE ADJACENT DUPLICATES</b>
    As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.
       LOOP AT TAB1.
        READ TABLE TAB2 INDEX SY-TABIX.
          IF TAB1 <> TAB2.                
          TAB_DIFFERENT = 'X'. EXIT.    
        ENDIF.                          
      ENDLOOP.                          
    ENDIF.                              
    IF TAB_DIFFERENT = SPACE.   " ...                             
    ENDIF.                              
    IF TAB1[] = TAB2[].    " ...              
    ENDIF.               
    Regards,
    Kumar.

  • KEPM deletion package doesn't work as expected - duplicate entries in COPA

    hello,
    I have used KEPM TCODE to delete entries in COPA version and what we have experienced is that it doesn't delete data for a particular company code which led to duplicates.
    Does anyone know the reason and how I can delete duplicate entries.
    Thanks,
    Bhat

    Hi Vaidya,
    KEPM does not physically delete data from CE2XXXX table. It passes a opposite entry to nullify the effect.
    If you are unable to delete it, i request you to give screen shots of Planning Level, Planning Package.
    Best Regards
    Surya

  • Device list has duplicate entries which I am unable to delete

    smart WiFi application device list has foreign an mullti[ple duplicate entries.  When I try todelete them I get "Unexpected Error" [object XMLDocument].

    “smart WiFi application” Are you referring to the user interface of the router which is the Linksys Smart Wifi? If it’s the Linksys Smart Wifi user interface of the router, how did you access it, via IP or router name? How did you log-in, via local or Linksys Smart Wifi account? What is the model # of your router and its current firmware? In the device list, how many icons do you have? How many actual devices you have in the network? Say for example you have a laptop and desktop, you can expect three icons on the device list. Each device on the network holds its own icon and name. If the name and icon doesn’t much to the device, you can change the name and icon to much the actual device. Sometimes the device list shows “network device”. For you to find out what device is that, check the IP and MAC address. Compare it to the actual device IP and MAC which can be found on the network properties of the device. If you have identify the devices and you still want to delete the un-identified device icon on the list. What you can try is to turn off the other devices in the network and take a look at closely the icons on the device list if one of them turns OFFLINE then you can remove that icon. You can now log-out from Linksys Smart Wifi portal which can be found on the upper right of the page. Clear you browser history and close it.  Power cycle the router by unplugging the power supply for 5 seconds and plug it back in. Turn ON your network device and try access the router Linksys Smart Wifi page and check the device list if you still have that “foreign and multiple duplicate entries”.

Maybe you are looking for