1
1
drop table if exists t1,t2;
2
create table t1 (name char(20) not null, primary key (name));
3
create table t2 (name char(20) binary not null, primary key (name));
4
insert into t1 values ("�");
5
insert into t1 values ("�");
6
insert into t1 values ("�");
7
insert into t2 select * from t1;
8
select * from t1 order by name;
13
select concat("*",name,"*") from t1 order by 1;
18
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
19
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
21
select * from t2 order by name;
26
select concat("*",name,"*") from t2 order by 1;
31
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
32
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
34
select name from t1 where name between '�' and '�';
38
select name from t2 where name between '�' and '�';
43
select name from t2 where name between '�' and '�';
46
2
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
47
3
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
48
4
select concat("-",a,"-",b,"-") from t1 where a="hello";
49
5
concat("-",a,"-",b,"-")
51
7
select concat("-",a,"-",b,"-") from t1 where a="hello ";
52
8
concat("-",a,"-",b,"-")
54
10
select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
55
11
concat("-",a,"-",b,"-")
57
13
select concat("-",a,"-",b,"-") from t1 where b="hello";
58
14
concat("-",a,"-",b,"-")
60
16
select concat("-",a,"-",b,"-") from t1 where b="hello ";
61
17
concat("-",a,"-",b,"-")
63
19
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
64
20
concat("-",a,"-",b,"-")
66
22
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
67
23
select concat("-",a,"-",b,"-") from t1;
68
24
concat("-",a,"-",b,"-")
71
27
select concat("-",a,"-",b,"-") from t1 where b="hello ";
72
28
concat("-",a,"-",b,"-")
74
30
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
75
31
concat("-",a,"-",b,"-")
78
34
create table t1 (b char(8));
79
35
insert into t1 values(NULL);
109
65
select * from t1 where lower(b)='bbb';
112
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
113
charset(a) charset(b) charset(binary 'ccc')
115
68
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
116
69
collation(a) collation(b) collation(binary 'ccc')
117
latin1_bin binary binary
70
utf8_bin binary binary
119
72
create table t1( firstname char(20), lastname char(20));
120
73
insert into t1 values ("john","doe"),("John","Doe");
134
87
firstname lastname
137
create table t1 (a binary);
90
create table t1 (a char);
138
91
show create table t1;
139
92
Table Create Table
140
t1 CREATE TABLE "t1" (
142
) ENGINE=MyISAM DEFAULT CHARSET=latin1
93
t1 CREATE TABLE `t1` (
144
create table t1 (col1 binary(4));
97
create table t2 (a varbinary);
98
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
99
create table t1 (col1 char(4));
145
100
insert into t1 values ('a'),('a ');
146
101
select hex(col1) from t1;
150
alter table t1 modify col1 binary(10);
105
alter table t1 modify col1 char(10);
151
106
select hex(col1) from t1;
155
110
insert into t1 values ('b'),('b ');
156
111
select hex(col1) from t1;
163
118
CREATE TABLE t1 (
164
a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
119
a varbinary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
167
122
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575');
174
129
1F9480179366F2BF567E1C4B964C1EF029087575
175
130
EXPLAIN SELECT hex(a) FROM t1 order by a;
176
131
id select_type table type possible_keys key key_len ref rows Extra
177
1 SIMPLE t1 index NULL idx 20 NULL 3 Using index
132
1 SIMPLE t1 index NULL idx 22 NULL 3 Using index
178
133
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
180
135
1F9480179366F2BF567E1C4B964C1EF029082020
182
137
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
183
138
id select_type table type possible_keys key key_len ref rows Extra
184
1 SIMPLE t1 ref idx idx 20 const 1 Using where; Using index
139
1 SIMPLE t1 ref idx idx 22 const 1 Using where; Using index
185
140
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908');