• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Deleting Duplicate Rows.

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IS there any way to eliminate duplicate rows?

Some times my table contains double entries(In all coloumns).
SO is there any way to remove the duplicates?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, and it has to do with a where clause to determine a duplicate with a sub-select (I think) and a rowid > rowid. Basically saving the first one it finds and deleting the others.

I just don't remember the exact query. But you can query for it at asktom.oracle.com

Copied from that site



that'll remove "dups" based on the column X (just partition by the "key to de-dup by")

If you have an index on that column (and at least one of the columns in the index is NOT NULLABLE),
then it'll use that index in the plan...



Good Luck

Mark
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


replace <table> with your table name
replace <all, columns, in, your, table> with all columns in your table.

The subquery will return just one rowid for each unique row (the lowest rowid).
The main query will delete all records that are not in this subquery. They are the duplicates.

carefull:
Take a backup of your table first! Be prepared to rollback! Try it on a test instance first! Disable autocommit!

Regards, Jan
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cumps,
I dont want to hijack this thread. Could you Please check your private message I sent. (I need some info on UMP exam).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic