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

2023-06-02数据库问题
11

本文介绍了MySQL 中区分大小写的排序规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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 中区分大小写的排序规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

MySQL GROUP BY DateTime +/- 3 秒
MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)...
2024-04-16 数据库问题
14