【发布时间】:2019-12-02 06:41:19
【问题描述】:
有人知道为什么会失败吗?
我创建了一个带有 char3 主键的 utf-8 表,当使用 MySQL Workbench 向其中插入记录时,它无法区分 A 和 Ä
我们正在使用 MySQL 5.1.73 和 Workbench 6.3.10
CREATE TABLE `test` (
`citycode` char(3) NOT NULL,
PRIMARY KEY (`citycode`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `test` (`citycode`) VALUES ('JLA');
INSERT INTO `test` (`citycode`) VALUES ('JLÄ');
Operation failed: There was an error while applying the SQL script to the database.
Executing:
INSERT INTO `trains4_copy`.`test` (`citycode`) VALUES ('JLA');
INSERT INTO `trains4_copy`.`test` (`citycode`) VALUES ('JLÄ');
ERROR 1062: 1062: Duplicate entry 'JLÄ' for key 'PRIMARY'
SQL Statement:
INSERT INTO `trains4_copy`.`test` (`citycode`) VALUES ('JLÄ')
【问题讨论】:
-
您的字符集可能是 utf8,但您为列
citycode设置的排序规则是什么? -
如果你想要
Ä=Æ,那么使用utf8_german2_ci。 utf8_slovak_ci 将Ä视为在“az”之后排序的字母;也许你想要那个?
标签: mysql utf-8 mysql-workbench