1
create table t1 (s1 varbinary(2), s2 varbinary(2));
2
insert into t1 values (0x4100,0x4100);
3
select length(concat('*',s1,'*',s2,'*')) from t1;
4
length(concat('*',s1,'*',s2,'*'))
7
insert into t1 values (0x4120,0x4120);
8
select length(concat('*',s1,'*',s2,'*')) from t1;
9
length(concat('*',s1,'*',s2,'*'))
12
create table t1 (s1 varbinary(20), s2 varbinary(20));
15
t1 CREATE TABLE `t1` (
16
`s1` varbinary(20) DEFAULT NULL,
17
`s2` varbinary(20) DEFAULT NULL
19
insert into t1 values (0x41,0x4100),(0x41,0x4120),(0x4100,0x4120);
20
select hex(s1), hex(s2) from t1;
25
select count(*) from t1 where s1 < s2;
29
create table t1 (s1 varbinary(2), s2 varchar(1));
30
insert into t1 values (0x41,'a'), (0x4100,'b'), (0x41,'c'), (0x4100,'d');
31
select hex(s1),s2 from t1 order by s1,s2;
38
create table t1 (s1 varbinary(2) primary key);
39
insert into t1 values (0x01);
40
insert into t1 values (0x0120);
41
insert into t1 values (0x0100);
42
select hex(s1) from t1 order by s1;
47
select hex(s1) from t1 where s1=0x01;
50
select hex(s1) from t1 where s1=0x0120;
53
select hex(s1) from t1 where s1=0x0100;
56
select count(distinct s1) from t1;
59
alter table t1 drop primary key;
60
select hex(s1) from t1 where s1=0x01;
63
select hex(s1) from t1 where s1=0x0120;
66
select hex(s1) from t1 where s1=0x0100;
69
select count(distinct s1) from t1;
73
select hex(cast(0x10 as binary(2)));
74
hex(cast(0x10 as binary(2)))
76
create table t1 (b varbinary(2), vb varbinary(2));
77
insert into t1 values(0x4120, 0x4120);
78
insert into t1 values(0x412020, 0x412020);
79
ERROR 22001: Data too long for column 'b' at row 1
81
create table t1 (c char(2), vc varchar(2));
82
insert into t1 values(0x4120, 0x4120);
83
insert into t1 values(0x412020, 0x412020);
85
Note 1265 Data truncated for column 'c' at row 1
86
Note 1265 Data truncated for column 'vc' at row 1
88
create table t1 (b varbinary(2), vb varbinary(2));
89
insert into t1 values(0x4120, 0x4120);
90
insert into t1 values(0x412020, NULL);
91
ERROR 22001: Data too long for column 'b' at row 1
92
insert into t1 values(NULL, 0x412020);
93
ERROR 22001: Data too long for column 'vb' at row 1