a table containing duplicates, here's the key
mysql> ALTER IGNORE TABLE table_name ADD UNIQUE(column_name)
Please note the keyword IGNORE in the above statement. That does the
work forcefully.
This blog has content related to Linux, Apache, MySQL, PHP, Perl, CSS, JavaScript and Free software/open source.
mysql> ALTER IGNORE TABLE table_name ADD UNIQUE(column_name)
Please note the keyword IGNORE in the above statement. That does the
work forcefully.
5 comments:
"If IGNORE is specified, only the first row is used of rows with duplicates on a unique key, The other conflicting rows are deleted. Incorrect values are truncated to the closest matching acceptable value." - don't use this if you want duplicates to remain.
Yes, that's true. But if your application is in the development mode, you can save time with IGNORE. Is there any better way? If you know, please post here :-)
Thank you Chorny!
Ketan
It is useful to try everything in practise anyway and I like that here it's always possible to find something new. :)
Nice dispatch and this enter helped me alot in my college assignement. Thank you on your information.
Post a Comment