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.
4 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
hi.. just dropping by here... have a nice day! http://kantahanan.blogspot.com/
Post a Comment