问题描述
MySQL 中是否有任何支持区分大小写的排序规则类型.我在 MySQL 中有所有类型的排序规则,它们的名称末尾都有 _ci,因此它们是不区分大小写的排序规则.
Is there any Collation type in MySQL which supports Case Sensitive. I had all type of collation in MySQL they all have _ci at the end of their name so they are case Insensitive collation.
推荐答案
根据 MySQL 手册 http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html 你应该能够将排序规则设置为 _cs
区分大小写.您可以通过执行 SHOW COLLATION WHERE COLLATION LIKE "%_cs"
查询来获取 _cs
排序规则的列表
According to MySQL Manual http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html you should be able to set collation to _cs
for case sensitivity. You can get a list of _cs
collations by executing SHOW COLLATION WHERE COLLATION LIKE "%_cs"
query
经过一些研究:
显然 MySQL 中没有 utf8_*_cs
(目前).如果您需要 utf8 字段区分大小写的排序规则,您应该使用 utf8_bin
.这会弄乱ORDER BY
,但这可以通过ORDER BY column COLLATE utf8_general_ci
Apparently there are no utf8_*_cs
in MySQL (yet). If you need case sensitive collation for utf8 fields, you should use utf8_bin
. This will mess up ORDER BY
, but this can be fixed by ORDER BY column COLLATE utf8_general_ci
来源:http://forums.mysql.com/read.php?103,19380,200971#msg-200971 和 http://forums.mysql.com/read.php?103,156527,198794#msg-198794
这篇关于MySQL 中区分大小写的排序规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!