简体   繁体   English

MySQL 中区分大小写的排序规则

[英]Case Sensitive collation in MySQL

Is there any Collation type in MySQL which supports Case Sensitive. MySQL 中是否有任何支持区分大小写的排序规则类型。 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 中有所有类型的排序规则,它们的名称末尾都有 _ci,因此它们是不区分大小写的排序规则。

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.根据 MySQL 手册http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html,您应该能够将排序_cs设置为_cs以区分大小写。 You can get a list of _cs collations by executing SHOW COLLATION WHERE COLLATION LIKE "%_cs" query您可以通过执行SHOW COLLATION WHERE COLLATION LIKE "%_cs"查询来获取_cs排序规则列表


After a little research:经过一番研究:

Apparently there are no utf8_*_cs in MySQL (yet).显然 MySQL 中没有utf8_*_cs (还)。 If you need case sensitive collation for utf8 fields, you should use utf8_bin .如果您需要 utf8 字段区分大小写的排序规则,您应该使用utf8_bin This will mess up ORDER BY , but this can be fixed by ORDER BY column COLLATE utf8_general_ci这会弄乱ORDER BY ,但这可以通过ORDER BY column COLLATE utf8_general_ci修复

Source: http://forums.mysql.com/read.php?103,19380,200971#msg-200971 and http://forums.mysql.com/read.php?103,156527,198794#msg-198794来源: http : //forums.mysql.com/read.php?103,19380,200971#msg-200971http://forums.mysql.com/read.php?103,156527,198794#msg-198794

尝试以_bin结尾的排序_bin ,例如latin1_binutf8_bin ,具体取决于您的字符集。

The new version of MySQL (8.0.1 and higher) comes (finally) with a set of utf8mb4_*_0900_as_cs collations. MySQL 的新版本(8.0.1 及更高版本)(最终)带有一组utf8mb4_*_0900_as_cs排序规则。

More about it here更多关于这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM