SQL:如何使用case敏感的utf8mb4_general_ci的唯一键创建表?
我正在使用phpmyadmin和PDO。 我的数据库使用UTF8MB4_GENERAR_CI。 看起来像这样。
CREATE TABLE `my_database`.`example` (
`id` INT NOT NULL AUTO_INCREMENT,
`code` VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE (`code`)
) ENGINE = InnoDB;
当我插入“ A”和“ A”时,我会遇到错误。 我通过将代码
列的整理更改为UTF8MB4_BIN来修复它。
有什么方法可以将UTF8MB4_GENERAR_CI与敏感情况使用? 我可以将其设置在phpmyadmin,PDO或SQL中吗?
I am using phpMyAdmin and PDO.
My database using utf8mb4_general_ci.
And look like this.
CREATE TABLE `my_database`.`example` (
`id` INT NOT NULL AUTO_INCREMENT,
`code` VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE (`code`)
) ENGINE = InnoDB;
I got an error when I inserted 'A' and 'a'.
I fix it by changing the Collation of the code
column to utf8mb4_bin.
Have any way to use utf8mb4_general_ci with sensitive cases?
Can I set it in phpMyAdmin, PDO, or SQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢@tkausl和@topsail。
utf8mb4_general_ci
包含_CI
对于情况不敏感。来自 https://stackoverflow.com/questions/questions/4558707/case-sensistival-collation-collation-collation-collation-collation-ing-mysql ,,
我应该将
utf8mb4_bin
用于我想要案例敏感的唯一列,我可以使用columtrate comletate utf8_general_ci
colute。Thank @tkausl and @topsail.
The
utf8mb4_general_ci
contain_ci
that for case insensitive.From https://stackoverflow.com/questions/4558707/case-sensitive-collation-in-mysql,
I should use
utf8mb4_bin
for the unique column that I want case sensitive and I can useORDER BY column COLLATE utf8_general_ci
.