Adsense Ad

Tuesday, 7 April 2020

Oracle Sql: How to delete duplicate records

Following are the queries to remove duplicate record from a table.

SQL > select * from names;

NAME AGE ------------------------------ ---------- Alan 50 Carrie 51 Tom 52 Alan 50

rows selected.

SQL > delete from names a where rowid > (select min(rowid) from names b where b.name=a.name and b.age=a.age);
row deleted.

SQL > select * from names;
NAME AGE ------------------------------ ---------- Alan 50 Carrie 51 Tom 52
rows selected.

No comments: