ci mysql in_mysql 的 case (in)sensitivity

在mysql中存在着各种utf8编码格式,如下表:

1)utf8_bin

utf8_bin将字符串中的每一个字符用二进制数据存储,区分大小写。

2)utf8_general_ci

utf8_genera_ci不区分大小写,ci为case insensitive的缩写,即大小写不敏感。

3)utf8_general_cs

utf8_general_cs区分大小写,cs为case sensitive的缩写,即大小写敏感。

执行如下命令:

create table test_bin (

name varchar(32) not null primary key,

age int unsigned not null

) engine = InnoDB COLLATE=utf8_bin;

create table test_ci (

name varchar(32) not null primary key,

age int unsigned not null

) engine = InnoDB COLLATE=utf8_general_ci;

create table test_cs (

name varchar(32) not null primary key,

age int unsigned not null

) engine = InnoDB COLLATE=utf8_general_cs;

1,2命令成功 3执行失败,不支持utf8_genral_cs。

insert into test_bin values('Alice', 18);

insert into test_bin values('alice', 20);

以上命令能够执行成功,因为utf8_bin是以十六进制方式存储数据,两条记录的主键不重复。

insert into test_ci values('Alice', 18);

insert into test_ci values('alilce', 20);

以上命令执行失败,因为utf8_general_ci不区分大小写,两条记录的主键重复。

最后 看下官方的文档

case (in)sensitivity

https://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html

problems

https://bugs.mysql.com/bug.php?id=65830

https://bugs.mysql.com/bug.php?id=50909

https://bugs.mysql.com/bug.php?id=63164

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值