Home >Database >Mysql Tutorial >MySQL默认校验规则不区分大小写_MySQL

MySQL默认校验规则不区分大小写_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:28:431099browse

bitsCN.com

MySQL默认校验规则不区分大小写

 

      背景:

系统中通过判断name是否存在决定是插入还是更新,由于是关键属性,name上加了唯一性约束。然而在一次数据同步时,总是报唯一性约束,保存失败。

 

      检查:

经核实,是该name由aaa变成了aAa,由于大小写不同,系统认为是一个新对象,做了save操作,但是数据库唯一性校验时认为已经存在,保存失败。

在MySQL中,对于Column Collate其约定的命名方法如下:

 

*_bin: binary case sensitive collation,也就是说是区分大小写的 

*_cs: case sensitive collation,区分大小写 

*_ci: case insensitive collation,不区分大小写

 

      解决:

修改数据库的默认校验规则为utf8_bin 

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn