Need help on How to delete duplicate data

Hi All
I need your help in finding the best way to delete duplicate data from a table.
Table is like
create table table1 (col1 varchar2(10), col2 varchar2(20), col3 varchar2(30));
Insert into table1 ('ABC', 'DEF','FGH');
Insert into table1 ('ABC', 'DEF','FGH');
Insert into table1 ('ABC', 'DEF','FGH');
Insert into table1 ('ABC', 'DEF','FGH');
Now I want a sql statement which will delete the duplicate rows and leaves 1 row of that data in the table. ie.in the above example delete 3 rows of duplicate data and leave a row of that data in the table. My oracle version is 8i.
Appreciate your help in advance.

Either of these will work, the best approach will depend on how big the table is, and how many duplicates there are.
SQL> SELECT * FROM table1;
COL1       COL2                 COL3
ABC        DEF                  FGH
ABC        DEF                  FGH
ABC        DEF                  FGH
ABC        DEF                  FGH
ABC        DEF                  IJK
BCD        EFG                  HIJ
BCD        EFG                  HIJ
SQL> DELETE FROM table1 o
  2  WHERE rowid <> (SELECT MAX(rowid)
  3                  FROM table1 i
  4                  WHERE o.col1 = i.col1 and
  5                        o.col2 = i.col2 and
  6                        o.col3 = i.col3);
4 rows deleted.
SQL> SELECT * FROM table1;
COL1       COL2                 COL3
ABC        DEF                  FGH
ABC        DEF                  IJK
BCD        EFG                  HIJ
SQL> ROLLBACK;
Rollback complete.
SQL> CREATE TABLE table1_tmp AS
  2  SELECT DISTINCT * FROM table1;
Table created.
SQL> TRUNCATE TABLE table1;
Table truncated.
SQL> INSERT INTO table1
  2  SELECT * FROM table1_tmp;
3 rows created.
SQL> SELECT * FROM table1;
COL1       COL2                 COL3
ABC        DEF                  FGH
ABC        DEF                  IJK
BCD        EFG                  HIJThere are other approaches as well (e.g. see the EXCEPTIONS INTO clause of the ALTER TABLE command), but these are the most straightforward.
HTH
John

Similar Messages

  • How to delete duplicate data that generated from csv file??

    The thing i have done is that i red all the data in the csv file without removing the duplicate data and display it.. For where i should have a known number of index (about 13), my main file should have 13 records no duplicate values. and how can my Java program update the corresponding record in the main file each time an index is updated??
    Hope somebody can assist me on this..it would be really helpful for me...
    Thank you.
    -Rao-
    Edited by: reemarao on Apr 1, 2010 3:58 AM

    Hi Sudhir,
    In case you have edit access in your system carry out the following procedure:
    1. Create an export datasource on your cube.
    2. Now create the update rules to your cube using the datamart Infosource.
    3. In the update rules multiply all the key figures by
    -1.
    4. Now create an infopackage and give the request id of the duplicate request as selection.
    5. Load the datamart request and do the data validation.
    If you do not ahve edit access there is no other alternative you would have to delete all the data and reconstruct the requests that you need.
    Bye
    Dinesh

  • HELP! how to delete duplicates in iPhoto?

    Every time i update iPhoto i get a number of duplicates (it varies from 1 extra to 12!).  This is not surprisingly REALLY ANNOYING.  How can I automatically delete these.  Manually will take weeks!

    Not sure what you are doing but that should not be happening. You need to post exact workflow and details and resolve your actual problem
    In answer to your question Duplicate Annihaliator or DeCloner
    LN

  • I need help in "HOW TO EXTEND THE DATA TYPE SYSTEM"......

    Hi All,
    I need to add new data type like SDO_GEOMETRY in spatial Oracle.
    I don't mean the User-Defined Datatype but new datatype embed in the database.
    I read the Data Cartridge Developer's Guide but it has info how to use more efficiently UDT through indexes.
    Anybody used the “Type System” under Databases and Extensibility Services?
    It might be written in C++ or Java but I do not know how.
    Any hints and help will be appreciated.
    Thanks,

    > In Figure 1-1 Oracle Services, there is a "Type System" as Oracle Services.
    The "Type System" is merely a compartmentalising the data type handling and implementation code/modules in Oracle.
    This covers all types. Oracle native types, user defined types (UDTs), etc.
    Saying that you want to create a new type in the "Type System" is basically saying you want to use the CREATE TYPE SQL command in Oracle.
    > So, I want new_type1 and new_type2 behave like other built-in types, just the way
    SDO_GEOMETRY works in Oracle Spatial Cartridge.
    Not familiar with the SDO_GEOMETRY. Why do you mention this type specifically? What do you want to do similar?
    > I have already done it with user-defined types. Now I need to do this way so that I can
    compare and contrast in terms of speed, space...etc for part of my research.
    Hmm.. I'm not sure what you are trying to compare ito of a UDT and Data Cartridge extensions. It is not one or the other. What research is this if I may ask?
    Simplistically you extend the Type System with a new UDT/ADT. And there you have a new type data can be used in the SQL Engine and the PL/SQL engine. The OCI (Oracle Call Interface) supports such types via the OCI object API calls - which means this new type can also be used from Oracle clients written in Delphi, C++, Java, etc.
    That new type can be a complex type. This type may need specific management code (memory management, context management, internationalisation, etc). To support this you can extend the UDT/ADT further by developing Cartridge Basic Service interfaces for the type - designing and writing management code to, for example, support specific internationalisation requirements when dealing with multibyte character sets.
    You can also extend the UDT/ADT to be custom managed ito indexing, determining query optimisation, computing costs of custom methods/functions/operators on this custom data type. These extensions are done by developing Data Cartridge interfaces for the type.
    Thus I cannot see what you are trying to compare. It is not one layer/interface versus another. These layers exist for all Oracle types (in the Type System). Oracle not only allows you to add to the top layer by adding/defining a new data type. It also allows you to customise (if needed) the layers below it.

  • Need help on how to construct proper data structure using vector

    I have several data files need to be loaded to my application. The data file has only 2 columns: "mean" and "standard deviation". The data file is looking like following:
    mean standard deviation
    217.0 27.3
    312.1 31.5
    I used two vectors to store the mean data and standard deviation data.
    Vector meanVec = new Vector();
    Vector stdVec = new Vector();
    the file is loaded once a time. so how to make a vector of vector to store the data like a matrix?
    In another word, when multiple files need to be loaded, how can I keep track and store these data to display in two table (or files) which can display mean data from all the files and std from all files, like the following:
    table1 or file1
    mean1 mean2
    217.0 282.3
    table2 or file2
    std1 std2
    27.3 27.9
    Any suggestion is greatly appreciated!

    If your application doesn't require to keep track of which mean (or std.dev.) values come from which file, whatever you are doing is just fine.
    Use ArraList in place of Vector, as Vector being part of older collection framework is avoided in newer programs (as far as I know).
    While reading each file line by line in a loop, store the first value on each line in one list and the second value in the other. After reading all the files, you would have two lists containing the mean and std. dev. values.

  • How to delete the data from partition table

    Hi all,
    Am very new to partition concepts in oracle..
    here my question is how to delete the data from partition table.
    is the below query will work ?
    delete from table1 partition (P_2008_1212)
    we have define range partition ...
    or help me how to delete the data from partition table.
    Thanks
    Sree

    874823 wrote:
    delete from table1 partition (P_2008_1212)This approach is wrong - as Andre pointed, this is not how partition tables should be used.
    Oracle supports different structures for data and indexes. A table can be a hash table or index organised table. It can have B+tree index. It can have bitmap indexes. It can be partitioned. Etc.
    How the table implements its structure is a physical design consideration.
    Application code should only deal with the logical data structure. How that data structure is physically implemented has no bearing on application. Does your application need to know what the indexes are and the names of the indexes,in order to use a table? Obviously not. So why then does your application need to know that the table is partitioned?
    When your application code starts referring directly to physical partitions, it needs to know HOW the table is partitioned. It needs to know WHAT partitions to use. It needs to know the names of the partitions. Etc.
    And why? All this means is increased complexity in application code as this code now needs to know and understand the physical data structure. This app code is now more complex, has more moving parts, will have more bugs, and will be more complex to maintain.
    Oracle can take an app SQL and it can determine (based on the predicates of the SQL), which partitions to use and not use for executing that SQL. All done totally transparently. The app does not need to know that the table is even partitioned.
    This is a crucial concept to understand and get right.

  • Please i need help to how to recover my camera roll photos i deleted them yersterday by accident im need with the ipod and i took the pictures with ipod but i want to know how to recover my photos in a easy fast FREE way as soon as porssible pleasse???

    please i need  help to how to recorver my cameral roll photos from my ipod in a easy FREE way as soon as possible

    Restore from backup if they are in a backup. Otherweise I know of no free way. These are paid and no one has said that they worked.
    iPhone Recovery Stick - recover deleted text messages & more
    Recover files from iPod Touch | Restore data iPod | iPod touch undelete, unformat

  • HT1918 I need to know how to delete my credit card from account because I know longer have a credit.  I just want to be able to up date my Apps but I can't now because there is a credit card on my account what do I need to delete it.

    I need to know how to delete my credit card from account because I know longer have a credit.  I just want to be able to up date my Apps but I can't now because there is a credit card on my account what do I need to delete it.

    I need to know how to delete my credit card from account because I know longer have a credit.  I just want to be able to up date my Apps but I can't now because there is a credit card on my account what do I need to delete it. Also my credit has expired so i need to delete it.

  • I have a 3g iphone and I need to know how to delete old photos from my phone!! I need the space but there is no way to delete the pictures!! Help!!!

    I have a 3g iPhone and I need to know how to delete old photos. Need to free up space and there is no clear way to delete these photos!! Can someone please let me know how to get rid of these pictures!!!! Help!!!

    There are a number of ways to delete pictures from the Camera Roll.  One is to open Camera Roll in the thumbnail view, tap the arrow button (top right), tap all the pictures you want to delete, tap the Delete button ant the bottom.  Photo Library pictures are deleted by unchecking Sync Photos on the Photos tab of your iTunes sync settings, followed by syncing your phone.

  • I need help! How can i spend my $0.46 cent? Can I delete it? Because I want to change to my country yet I cannot due to remaining dollar balance..

    I need help! How can i spend my $0.46 cent? Can I delete it? Because I want to change to my country yet I cannot due to remaining dollar balance..

    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • Hi, I need help on how to remove my credit card data on my friend's iPad?

    Hi, my friend borrowed my credit card to purchase smart office 2. I need help on how to change or remove my credit card details on her iPad. It turned out when I tried purchasing a game that i was again automatically charged. Thanks for helping me.

    Settings->iTunes and App Stores->Apple ID->View Apple ID->Payment Information, Set the Payment Type to "None".

  • Going to sell my Ipad 1 and need to know how to delete my information, help

    I am going to sell my Ipad 1 and need to know how to delete my personal information. Please advise.

    Connect it to your computer, open the iTunes app and restore the iPad to the factory settings. Do not sync the iPad after you have restored it.

  • How to delete duplicate records in cube

    Hi,
    can u help me how to delete the duplicate records in my cube
    and tell me some predifined cubes and data sourcess for MM and SD modules

    Hi Anne,
    about "duplicate records" could you be more precise?.
    The must be at least one different Characteristic to distinguish one record from the other (at least Request ID). In order to delete Data from InfoCubes (selectively) use ABAP Report RSDRD_DELETE_FACTS (be carefull it does not request any confirmation as in RSA1 ...).
    About MM and SD Cubes see RSA1 -> Business Content -> InfoProvider by InfoAreas. See also for MetadataRepository about the same InfoProviders.
    About DataSources just execute TCode LBWE in you source sys: there you see all LO-Cockipt Extrators.
    Hope it helps (and if so remember reward points)
    GFV

  • How to delete aggreagetd data in a cube without deleting the Aggregates?

    Hi Experts,
    How to delete aggreagetd data in a cube without deleting the Aggregates?
    Regards
    Alok Kashyap

    Hi,
    You can deactivate the aggregate. The data will be deleted but structure will remain.
    If you switch off the aggregates it wont be identified by the OLAP processor. report will fetch the data directly from the cube. Switching off the aggreagte won't delete any data,but temporarly the aggregate will not be availbale as if it is not built on the info cube. No reporting is not possible on swtiched off aggregates. The definition of the aggregate is not deleted.
    You can temporarily switch off an aggregate to check if you need to use it. An aggregate that is switched off is not used when a query is executed.This aggregate will be having data from the previous load's. If the aggregate is switched off means it wont be available for reporting but data can be rolled up into it.
    If u deactivate the aggregates the data will be deleted from the aggregates and the aggregate structure will remain the same.
    The system deletes all the data and database tables of an aggregate. The definition of the aggregate is not deleted.
    Later when you need those aggregate once again you have to create it from scratch.
    Hope this helps.
    Thanks,
    JituK

  • How to delete timesheet data in MAM 2.5?

    Hello experts,
    I need to find a way how to delete timesheet data (Mam010Item090) from the MI Client (SP18) running MAM 2.5. The task seemed to be quite straightforward however for some reason all the notifications are staying in IN_SYNC state which prevents me from deleting them.
    Anyone knows why they stay in this state, possibly what to do to change their state?
    Any help would be greatly appreciated.
    Regards,
    Frank

    Hi,
    1. MAM010Item090 is notification long text, not timesheet. So there is some confusion on what exactly you want to delete.
    2. Records in DB have three statuses: G - global, which means data was synhronised with the backend, L - local, data was created on the device but not synchronised to the backend yet, S- In-sync, synchronisation process in Mobile Infrastructure is always asynchronous which means that there are always 2 requests for data exchange to process one data update transaction. When first request was sent from the device to the middleware but no response received yet - data record will be in status in-Sync.
    Data can stay in status "S" for multiple reasons. Some examples: when data change request (BAPI) was executed it ended with ABEND or didn't provide a proper response, device DB got corrupted (exception thrown while synchronising), mobileID has some qeues in status "I-Waiting", etc.
    There is no universal solution on how to fix the situation: it might be a client reset, or SyncBo got deactivated (and that caused I-Waiting situation), etc.
    And standard MAM has no such object as timesheet. Did you mean time confirmation?
    Regards,
    Larissa Limarova

Maybe you are looking for

  • Clearing message area in Web UI

    Dear Experts, I have kept passport field as mandatory in account creation application. I am displaying custom error message if its not entered. Assume end user id not entering passport and fills other fields and presses enter. In EH_ONSUBMITONENTER e

  • Stabilize in iMovie 10.0.1 seems to unstabilize!

    I haven't tested this much, but with an old project I converted from iMovie v9 to the new iMovie v10, which was stabilized successfully before, the new iMovie seems to do the opposite of stabilizing when I apply stabilization. Believe it or not, inst

  • Publish using iWeb 09 using any WebDAV compliant web development software

    Our School is looking at moving to the Mac Platform. We currently use Frontpage to publish our website. Our current web host says that we can use "any WebDAV compliant web development software to publish our site. Is there a way to do this using iWeb

  • Looking for a miracle

    Hello world. I'm messing with a wrt54gl wireless router. After getting this router I started having repetative interruptions on wired connections. We're talking somewhere in the tune of 4 or 5 times an hour. Normally just 3-4 seconds each time. Poste

  • Shutdown time controlled

    Hello guys, so far I shutdown my machine via shutdown -h +time when I want to terminate it time controlled. But often there are still some programs running like firefox. Is there any program-friendly method to shutdown? shutdown -h kills all apps ins