_cs, _ci, or _bin,
DROP TABLE IF EXISTS `w_ci_bin_cs`;
CREATE TABLE `w_ci_bin_cs` (
`pkey` int(11) NOT NULL AUTO_INCREMENT,
`w` char(255) NOT NULL DEFAULT 'W',
`w_ci` char(255) NOT NULL DEFAULT 'a',
`w_bin` char(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT 'bin',
`w_ci_bin` char(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT 'ci_bin',
`w__bin` char(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '__bin',
PRIMARY KEY (`pkey`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of w_ci_bin_cs
-- ----------------------------
INSERT INTO `w_ci_bin_cs` VALUES ('', 'w', 'a', 'bin', 'ci_bin', '__bin');
INSERT INTO `w_ci_bin_cs` VALUES ('', 'W', 'A', 'BIN', 'CI_BIN', 'BIN');
mysql> SELECT * FROM w_ci_bin_cs;
+------+---+------+-------+----------+--------+
| pkey | w | w_ci | w_bin | w_ci_bin | w__bin |
+------+---+------+-------+----------+--------+
| 1 | w | a | bin | ci_bin | __bin |
| 2 | W | A | BIN | CI_BIN | BIN |
+------+---+------+-------+----------+--------+
2 rows in set (0.00 sec) mysql> SELECT * FROM w_ci_bin_cs WHERE w='w';
+------+---+------+-------+----------+--------+
| pkey | w | w_ci | w_bin | w_ci_bin | w__bin |
+------+---+------+-------+----------+--------+
| 1 | w | a | bin | ci_bin | __bin |
| 2 | W | A | BIN | CI_BIN | BIN |
+------+---+------+-------+----------+--------+
2 rows in set (0.00 sec) mysql> SELECT * FROM w_ci_bin_cs WHERE w_ci='a';
+------+---+------+-------+----------+--------+
| pkey | w | w_ci | w_bin | w_ci_bin | w__bin |
+------+---+------+-------+----------+--------+
| 1 | w | a | bin | ci_bin | __bin |
| 2 | W | A | BIN | CI_BIN | BIN |
+------+---+------+-------+----------+--------+
2 rows in set (0.00 sec) mysql> SELECT * FROM w_ci_bin_cs WHERE w_bin='BIN';
+------+---+------+-------+----------+--------+
| pkey | w | w_ci | w_bin | w_ci_bin | w__bin |
+------+---+------+-------+----------+--------+
| 2 | W | A | BIN | CI_BIN | BIN |
+------+---+------+-------+----------+--------+
1 row in set (0.00 sec) mysql>
11.1.1 Character Sets and Collations in General
A character set is a set of symbols and encodings. A collation is a set of rules for comparing characters in a character set. Let's make the distinction clear with an example of an imaginary character set.
Suppose that we have an alphabet with four letters: A, B, a, b. We give each letter a number: A = 0, B = 1, a = 2, b = 3. The letter A is a symbol, the number 0 is the encoding for A, and the combination of all four letters and their encodings is a character set.
Suppose that we want to compare two string values, A and B. The simplest way to do this is to look at the encodings: 0 for A and 1 for B. Because 0 is less than 1, we say A is less than B. What we've just done is apply a collation to our character set. The collation is a set of rules (only one rule in this case): “compare the encodings.” We call this simplest of all possible collations a binary collation.
But what if we want to say that the lowercase and uppercase letters are equivalent? Then we would have at least two rules: (1) treat the lowercase letters a and b as equivalent to A and B; (2) then compare the encodings. We call this a case-insensitive collation. It is a little more complex than a binary collation.
In real life, most character sets have many characters: not just A and B but whole alphabets, sometimes multiple alphabets or eastern writing systems with thousands of characters, along with many special symbols and punctuation marks. Also in real life, most collations have many rules, not just for whether to distinguish lettercase, but also for whether to distinguish accents (an “accent” is a mark attached to a character as in German Ö), and for multiple-character mappings (such as the rule that Ö = OE in one of the two German collations).
MySQL can do these things for you:
Store strings using a variety of character sets.
Compare strings using a variety of collations.
Mix strings with different character sets or collations in the same server, the same database, or even the same table.
Enable specification of character set and collation at any level.
To use these features effectively, you must know what character sets and collations are available, how to change the defaults, and how they affect the behavior of string operators and functions.
//极简原则 KEEP IT SIMPLE
_cs, _ci, or _bin,的更多相关文章
- MySQL字符集
字符集的选择 1.如果数据库只需要支持中文,数据量很大,性能要求也很高,应该选择双字节定长编码的中文字符集(如GBK).因为相对于UTF-8而言,GBK"较小",每个汉字只占2个字 ...
- [MySQL Reference Manual] 10 全球化
10.全球化 本章主要介绍全球化,包含国际化和本地化,的一些问题: · MySQL在语句中支持的字符集 · 如何为服务配置不同的字符集 · 选择错误信息 ...
- mysql笔记04 MySQL高级特性
MySQL高级特性 1. 分区表:分区表是一种粗粒度的.简易的索引策略,适用于大数据量的过滤场景.最适合的场景是,在没有合适的索引时,对几个分区进行全表扫描,或者是只有一个分区和索引是热点,而且这个分 ...
- 9.Mysql字符集
9.字符集9.1 字符集概述 字符集就是一套文字符号及其编码.比较规则的集合. ASCII(American Standard Code for Information Interchange)字符集 ...
- MySQL 支持utf8mb4
utf8mb4 utf8mb3 utf8 Refer to The utf8mb4 Character Set The utf8 Character Set (Alias for utf8mb3) M ...
- mysql字符集和字符排序
mysql的字符集和字符序: 字符序:字符序(Collation)是指在同一字符集内字符之间的比较规则 一个字符序唯一对应一种字符集,但一个字符集可以对应多种字符序,其中有一个是默认字符序 ...
- Mysql系列-字符集
字符集 怎样选择合适的字符集 如果应用程序需要发布到很多国家和地区,需要支持各种各样的文字,则选择Unicode编码,Mysql中即UTF-8.q如果需要将数据导入数据库,这时候要注意数据库字符集对数 ...
- 数据库_11_1~10总结回顾+奇怪的NULL
校对集问题: 比较规则:_bin,_cs,_ci利用排序(order by) 另外两种登录方式: 奇怪的NULL: NULL的特殊性:
- 干货:鲜为人用的MySQL高级特性与玩法!
上一篇文章<万字总结:学习MySQL优化原理,这一篇就够了!>文末给大家留有两个开放的问题: 有非常多的程序员在分享时都会抛出这样一个观点:尽可能不要使用存储过程,存储过程非常不容易维护, ...
随机推荐
- X-WAF简单测试体验
X-WAF 最近才关注到的一款云WAF,花了一些时间搭建了一个环境,并做了一些测试,感觉比较适合新手来练习WAF Bypass. X-WAF是一款适用中.小企业的云WAF系统,让中.小企业也可以非常方 ...
- python中的数据类型与json的数据类型之间的转化
什么是json: JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programm ...
- React Native(十一)——按钮重复点击事件的处理
最初开始做后台管理系统的时候,就曾遇到过这样一种场景:"快速点击确认按钮,就会对此触发确认事件,导致多次请求数据库":于是最终我们得当的通过处理那个确认button,解决了上述问题 ...
- 由于更换硬盘没有删除系统自启动读取挂载硬盘导致系统报错:fsck.ext4 unable to resolve 'UUID=a4a7a0f7-b54f-4774-9fb1'
由于更换硬盘没有删除系统自启动读取挂载硬盘导致系统报错:fsck.ext4 unable to resolve 'UUID=a4a7a0f7-b54f-4774-9fb1' 此时进入系统已root模式 ...
- 【swagger学习】.net WebApi中使用swagger
我在WebApi中使用swagger的时候发现会出现很多问题,搜索很多地方都没找到完全解决问题的方法,后面自己解决了,希望对于遇到同样问题朋友有帮助.我将先一步一步的演示项目中解决swagger遇到问 ...
- django进阶-小实例
前言: 这篇博客对上篇博客django进阶作下补充. 一.效果图 前端界面较简单(丑),有两个功能: 从数据库中取出书名 eg: 新书A 在form表单输入书名,选择出版社,选择作者(多选),输入完毕 ...
- 【Laravel5.5】 Laravel 在views中加载公共页面怎么实现
背景: 在做后台功能时候,我们需要把头部和尾部摘出来作为公共模板使用 1:我们使用了Blade模板,并创建一个header.blade.php作为通用的模板.将子页面作为yield输出: header ...
- java高级---->Thread之单例模式的使用
这里我们介绍一下在多线程中如何安全正确的编写单例模式的代码.不知为何,恰如其分的话总是姗姗来迟,错过最恰当的时机. 多线程中的单例模式 这里面通过代码来体会一下在多线程中如何正确的编写单例模式的代码. ...
- hihoCoder挑战赛28 题目1 : 异或排序
题目1 : 异或排序 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个长度为 n 的非负整数序列 a[1..n] 你需要求有多少个非负整数 S 满足以下两个条件: ...
- 【黑金原创教程】【FPGA那些事儿-驱动篇I 】实验十五:FIFO储存模块(同步)
实验十五:FIFO储存模块(同步) 笔者虽然在实验十四曾解释储存模块,而且也演示奇怪的家伙,但是实验十四只是一场游戏而已.至于实验十五,笔者会稍微严肃一点,手动建立有规格的储存模块,即同步FIFO.那 ...