Something about Nothing

some thoughts about nothing

Delete Duplicate Rows From an Oracle Table

without comments

Yesterday i was loading data into tables, some how i messed up loading the same data two times.

Here is a solution how to remove duplicate rows:

DELETE FROM THE_TABLE
WHERE rowid not in
(SELECT MIN(rowid)
FROM our_table
GROUP BY COL1, COL2, COL3… ) ;

Here COL1, COL2, COL3 constitute the identifying key for each record.

The GROUP BY is used on the columns that make the primary key for the table. This script deletes each row in the group after the first row.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • e-mail
  • Furl

Written by mansoor

January 23rd, 2007 at 10:58 am

Posted in Default

Leave a Reply