Daniel Kasak wrote:
> gerald_clark wrote:
>
>> Batara Kesuma wrote:
>>
>>> Hi,
>>> I have a table that looks like:
>>> CREATE TABLE `message_inbox` (
>>> `member_id` mediumint(8) unsigned NOT NULL default '0',
>>> `message_id` int(10) unsigned NOT NULL default '0',
>>> `new` enum('y','n','replied') NOT NULL default 'y',
>>> `datetime` datetime default NULL,
>>> KEY `idx_1` (`member_id`,`new`),
>>> KEY `idx_2` (`member_id`,`datetime`)
>>> ) TYPE=InnoDB
>>>
>>>
>>> Now, I want to add a primary key to it.
>>> ALTER TABLE message_inbox ADD PRIMARY KEY (member_id, message_id)
>>>
>>> But there are already some duplicated entries. ERROR 1062: Duplicate
>>> entry '10244-80871' for key 1
>>>
>>> How can I tell MySQL to delete the duplicated entry and continue to
>>> make primary key? Is there any efficient way to do this? Thank you
>>> very much.
>>>
>>>
>> try ALTER IGNORE TABLE.
>
>
>
> That hardly seems like a solution. If the above works, then I'd call
> that 'feature' a bug.
What an odd statement.
The ignore option is there to allow you to create a unique index,
discarding duplicates.
Since it does exactly what was asked for, why doesn't it seem like a
solution.
Why is something that does what it was designed to do a bug?