What is this Site!!

All about Real time requirements in Orale Stay Tune!!
Showing posts with label Deleting duplicate rows in the table. Show all posts
Showing posts with label Deleting duplicate rows in the table. Show all posts

Sunday, January 6, 2008

Deleting duplicate rows in the table

I am searching for a way to delete the duplicate records in a table..
Is anybody having efficient way to do it..?



The command is:

DELETE dv
FROM a WHERE rowid <
(SELECT MIN(rowid)
FROM b
WHERE a.dv = b.dv);

i.e. if the table name is emp and the dupicate column value is ename:

DELETE ename
FROM emp a
WHERE rowid <
(SELECT MIN(rowid)
FROM emp b
WHERE a.ename = b.ename)

Another solution is:

delete from where rowid not in (
select max(rowid) from group by );