MySQL Forums
Forum List  »  InnoDB

UNIQUE CONTRAINT with CHARACTER SET UTF8
Posted by: Ringo Crossfire
Date: June 24, 2008 09:16PM

Hi all,

I have a problem when using a column with character set UTF8 as a unique constraint.
What I have done as following:

Step 1: Create table

CREATE TABLE `mapping` (
`id` bigint(20) NOT NULL auto_increment,
`mkey` varchar(200) NOT NULL,
`mvalue` varchar(200) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `mkey` (`mkey`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

Step 2: insert the first row

insert into mapping (mkey, mvalue) values('hùng', 'anh hùng'); ---> OK

Step 3: insert the second row

insert into mapping (mkey, mvalue) values('hưng', 'anh hưng'); ---> ERROR as below:
#1062 - Duplicate entry 'hưng' for key 2.

I don't know why the two different words 'hùng' and 'hưng' are treated as the same.
Could anyone tell me why and show me how to solve this problem?

I appreciate it.

Ringo

Options: ReplyQuote


Subject
Views
Written By
Posted
UNIQUE CONTRAINT with CHARACTER SET UTF8
8819
June 24, 2008 09:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.