我有一个包含2列的表Labels
:
+-------------+--------------+-------------+
| Column Name | Type | Key |
+-------------+--------------+-------------+
| id | integer | primary key |
| label | varchar(255) | unique |
+-------------+--------------+-------------+
在此表中,我已经有如下记录:
id: 1, label: 'café'
现在我想添加更多记录如下:
id: auto, label: 'cafe'
但是当我尝试插入时,会出现重复错误
(1062, "Duplicate entry 'cafe' for key 'label_2'") [SQL: u'INSERT INTO vocabulary (label) VALUES (%s)'] [parameters: (u'cafe',)]
在这种情况下,你们可以帮助我吗?
有关我的数据库的更多信息:字符集:utf8,collate:utf8mb4_unicode_ci
更新:创建表
CREATE TABLE `labels` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`label` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `label_2` (`label`),
KEY `label` (`label`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
答案 0 :(得分:4)
就class People{
...
private:
vector<Car*> _pointer;
};
是唯一键而言,您无法在该列中插入重复值。
由于您要区分label
和café
,因此您需要使用utf8_bin排序规则。
请尝试以下查询。
cafe
希望这会有所帮助。