什么是校对规则?
当前字符集内,字符的比较规则。
显示比较规则:
show collation like 'gbk%'
可以看到:字符集_地区_比较规则(ci/cs/bin)
ci:不区分大小写
cs:区分大小写
bin:字节比较
修改表的校对规则:
alter table tb_name collate gbk_bin;
以 gbk 字符为例:
在创建表时,可以指定字符集和校对规则
create table test01 (
name varchar(10),
age int
)character set gbk collate gbk_bin;
插入数据进行效果演示
insert into test01 values('AAA',23);
insert into test01 values('bbb',22);
insert into test01 values('CCC',20);
select * from test01 order by name;