List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:June 30 2008 12:07am
Subject:Re: convertion to utf-8
View as plain text  
In the last episode (Jun 29), Pooly said:
> Hi,
> 
> I'm trying to convert my tables to UTF8 but I'm getting the following error:
> ERROR 1062 (23000): Duplicate entry 'Zorglüb' for key 1
> 
> Not too sure why I'm getting this error since the current (latin1) data are:
> mysql> select * from topics_lookup where label like 'Zor%';
> +----------+----------+------+
> | label    | topic_id | main |
> +----------+----------+------+
> | Zorglub  |       72 |    0 |
> | Zorglüb  |       72 |    1 |
> +----------+----------+------+
> 2 rows in set (0.00 sec)
> 
> There is a unique index on label, however the 2 data are different.
> 
> Any ideas ?

I can't reproduce this.  Can you provide example commands demonstrating
your problem?

mysql> create table mytable ( label varchar(200) primary key );       
Query OK, 0 rows affected (0.01 sec)

mysql> show create table mytable;
+---------+--------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                  
                                          |
+---------+--------------------------------------------------------------------------------------------------------------------------+
| mytable | CREATE TABLE `mytable` (
  `label` varchar(200) NOT NULL,
  PRIMARY KEY (`label`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | 
+---------+--------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> insert into mytable values ('Zorglub'), ('Zorglüb');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from mytable;                                     
+---------+
| label   |
+---------+
| Zorglub | 
| Zorglüb | 
+---------+
2 rows in set (0.00 sec)

mysql> alter table mytable charset=utf8;
Query OK, 2 rows affected (0.02 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> alter table mytable change column label label varchar(200) character set utf8;
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> show create table mytable;
+---------+-----------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                  
                                                   |
+---------+-----------------------------------------------------------------------------------------------------------------------------------+
| mytable | CREATE TABLE `mytable` (
  `label` varchar(200) NOT NULL DEFAULT '',
  PRIMARY KEY (`label`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 | 
+---------+-----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from mytable;
+---------+
| label   |
+---------+
| Zorglub | 
| Zorglüb | 
+---------+
2 rows in set (0.00 sec)

mysql> 


-- 
	Dan Nelson
	dnelson@stripped
Thread
convertion to utf-8Pooly29 Jun
  • Re: convertion to utf-8Dan Nelson30 Jun
    • Re: convertion to utf-8Pooly30 Jun
      • Re: convertion to utf-8Dan Nelson1 Jul
        • Re: convertion to utf-8Pooly3 Jul
  • RE: convertion to utf-8Jerry Schwartz30 Jun