mysql字符集校对规则有哪些

这篇文章给大家介绍MySQL字符集校对规则有哪些,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

创新互联公司主要从事网站设计、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务寻乌,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108

目前mysql默认的校对规则除binary charset为binary外,都为ci,即大小写不敏感,既然这种校验规则容易出问题,那么为什么还要默认为这样的规则呢?有句古话叫做存在即合理,不知道为什么mysql采用了这样的默认规则呢?

查了下oracle中的校验规则,默认为binary,顺便查了下文档关于该参数的解释:

http://download.oracle.com/docs/cd/B28359_01/server.111/b28320/initparams145.htm#REFRN10127

Note:

Setting NLS_SORT to anything other than BINARY causes a sort to use a full table scan, regardless of the path chosen by the optimizer. BINARY is the exception because indexes are built according to a binary order of keys. Thus the optimizer can use an index to satisfy the ORDER BY clause when NLS_SORT is set to BINARY. If NLS_SORT is set to any linguistic sort, the optimizer must include a full table scan and a full sort in the execution plan.

ps:题外--

前些日子还感叹,mysql的文档结构不说怎么样吧,但是mysql有一个亮点就是注册用户可以在在线文档上添加comments,这些comments的用途想想都该知道的吧。

不经意间发现oracle 11g文档也增加了相应的模块,oracle总是在不断吸收别人的长处不断改进,赞一个!

回到正题,看了oracle关于该参数的说明,那不由得想到,mysql可能默认是按照linguistic语义来进行存储的吧,而这或许也是其多数用户需求?暂时没有答案了。

附1:mysql中默认字符集校验规则:

alipay@(none) 10:11:56>show charset;
+----------+-----------------------------+---------------------+--------+
| Charset | Description | Default collation | Maxlen |
+----------+-----------------------------+---------------------+--------+
| dec8 | DEC West European | dec8_swedish_ci | 1 |
| cp850 | DOS West European | cp850_general_ci | 1 |
| hp8 | HP West European | hp8_english_ci | 1 |
| koi8r | KOI8-R Relcom Russian | koi8r_general_ci | 1 |
| latin1 | cp1252 West European | latin1_swedish_ci | 1 |
| latin2 | ISO 8859-2 Central European | latin2_general_ci | 1 |
| swe7 | 7bit Swedish | swe7_swedish_ci | 1 |
| ascii | US ASCII | ascii_general_ci | 1 |
| hebrew | ISO 8859-8 Hebrew | hebrew_general_ci | 1 |
| koi8u | KOI8-U Ukrainian | koi8u_general_ci | 1 |
| greek | ISO 8859-7 Greek | greek_general_ci | 1 |
| cp1250 | Windows Central European | cp1250_general_ci | 1 |
| gbk | GBK Simplified Chinese | gbk_chinese_ci | 2 |
| latin5 | ISO 8859-9 Turkish | latin5_turkish_ci | 1 |
| armscii8 | ARMSCII-8 Armenian | armscii8_general_ci | 1 |
| utf8 | UTF-8 Unicode | utf8_general_ci | 3 |
| cp866 | DOS Russian | cp866_general_ci | 1 |
| keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | 1 |
| macce | Mac Central European | macce_general_ci | 1 |
| macroman | Mac West European | macroman_general_ci | 1 |
| cp852 | DOS Central European | cp852_general_ci | 1 |
| latin7 | ISO 8859-13 Baltic | latin7_general_ci | 1 |
| cp1251 | Windows Cyrillic | cp1251_general_ci | 1 |
| cp1256 | Windows Arabic | cp1256_general_ci | 1 |
| cp1257 | Windows Baltic | cp1257_general_ci | 1 |
| binary | Binary pseudo charset | binary | 1 |
| geostd8 | GEOSTD8 Georgian | geostd8_general_ci | 1 |
+----------+-----------------------------+---------------------+--------+
27 rows in set (0.00 sec)

附2:oracle nls_sort

ops$admin@test>select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

ops$admin@test>select * from v$nls_parameters where parameter ='NLS_SORT';

PARAMETER VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_SORT BINARY

关于mysql字符集校对规则有哪些就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


网站栏目:mysql字符集校对规则有哪些
网址分享:http://myzitong.com/article/gsccsd.html