Deleting Duplicate Database RowsPosted by Roger Keays, 13 July 2008, 9:20 PM |
Coming up with a query to find duplicate rows in a database is not as easy as it should be and always turns out dog slow. Here's a simple alternative which I used when I had to do just that:
- Dump the database.
- Delete all the records.
- Add a UNIQUE constraint on the natural key.
- Reload the records from the database dump.
If you have duplicates in the dump, the INSERT will fail and they won't make it back into the database.
Easy or WHAT?!
| << Packaging Your Facelets in JARs | Back to Blog | position: fixed on IE6 >> |
Add a comment
Please visit http://www.ninthavenue.com.au/blog/deleting-duplicate-database-rows to add your comments.