MySQL 中区分大小写的排序规则
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4558707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Case Sensitive collation in MySQL
提问by Keyur Padalia
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 中是否有任何支持区分大小写的排序规则类型。我在 MySQL 中有所有类型的排序规则,它们的名称末尾都有 _ci,因此它们是不区分大小写的排序规则。
回答by German Rumm
According to MySQL Manual http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.htmlyou 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 手册http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html,您应该能够将排序规则设置_cs
为区分大小写。您可以_cs
通过执行SHOW COLLATION WHERE COLLATION LIKE "%_cs"
查询来获取排序规则列表
After a little research:
经过一番研究:
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
显然utf8_*_cs
MySQL中没有(还)。如果您需要 utf8 字段区分大小写的排序规则,您应该使用utf8_bin
. 这会搞砸ORDER BY
,但这可以通过ORDER BY column COLLATE utf8_general_ci
Source: http://forums.mysql.com/read.php?103,19380,200971#msg-200971and http://forums.mysql.com/read.php?103,156527,198794#msg-198794
来源:http: //forums.mysql.com/read.php?103,19380,200971#msg-200971和http://forums.mysql.com/read.php?103,156527,198794#msg-198794
回答by Neil E. Pearson
Try a collation ending in _bin
, such as latin1_bin
or utf8_bin
, depending on your character set.
根据您的字符集尝试_bin
以latin1_bin
或结尾的排序规则utf8_bin
。