Another approach would be :
delete from TABLE_NAME T where rowid not in
(select max(rowid)
from TABLE_NAME R
where R.common_column = T.common_column;) ;
Here common_column is the criteria for filtering out duplicates.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Technically though if 3 copies of a single row existed you would only delete 1 with that script, hence why I used the 1 to keep instead of 1 to delete
Nope. Take a look at it once again. I delete those tuples who don't satisfy the criteria of having the max ROWID. In any case when duplicate exists, only one row will have the max rowid among all the duplicates. Hence the query. Try running it and you will know.
> Also in large tables that will be much slower
Correlated queries are generally faster as compared to other types of queries. On what basis can you say that the query would be slow ?
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734