1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
create database mysqltest collate = utf8_bin;
show create database mysqltest;
Database Create Database
mysqltest CREATE DATABASE `mysqltest` COLLATE = utf8_bin
alter database mysqltest collate = utf8_general_ci;
show create database mysqltest;
Database Create Database
mysqltest CREATE DATABASE `mysqltest`
alter database mysqltest collate = utf8_bin;
show create database mysqltest;
Database Create Database
mysqltest CREATE DATABASE `mysqltest` COLLATE = utf8_bin
use mysqltest;
create table t1 (a varchar(10));
create table t2 (a varchar(10)) collate = utf8_general_ci;
insert into t1 values ('a'),('A'),('aA'),('Aa'),('ab'),('Ab');
insert into t2 values ('a'),('A'),('aA'),('Aa'),('ab'),('Ab');
select * from t1 order by a;
a
A
Aa
Ab
a
aA
ab
select * from t2 order by a;
a
a
A
aA
Aa
ab
Ab
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` varchar(10) DEFAULT NULL
) ENGINE=InnoDB
select count(*) from t1 where a='a';
count(*)
1
select count(*) from t2 where a='a';
count(*)
2
select count(*) from t1 where a like 'a%';
count(*)
3
select count(*) from t2 where a like 'a%';
count(*)
6
drop table if exists t1;
drop table if exists t2;
drop database if exists mysqltest;
|