2007-11-20 16:04:07 +01:00
|
|
|
|
---- Partitioning and char data type
|
|
|
|
|
create table t1 (a char(255) not null, primary key(a)) engine='MyISAM'
|
|
|
|
|
partition by key (a) (
|
2008-02-06 15:13:56 +01:00
|
|
|
|
partition pa1 max_rows=20 min_rows=2,
|
|
|
|
|
partition pa2 max_rows=30 min_rows=3,
|
|
|
|
|
partition pa3 max_rows=30 min_rows=4,
|
|
|
|
|
partition pa4 max_rows=40 min_rows=2);
|
2007-02-06 13:35:54 +01:00
|
|
|
|
show create table t1;
|
|
|
|
|
Table Create Table
|
|
|
|
|
t1 CREATE TABLE `t1` (
|
2007-11-20 16:04:07 +01:00
|
|
|
|
`a` char(255) NOT NULL,
|
|
|
|
|
PRIMARY KEY (`a`)
|
2008-02-06 15:13:56 +01:00
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
|
2007-11-20 16:04:07 +01:00
|
|
|
|
insert into t1 values (repeat('a',255)), ('b'), (repeat('a',128)), (repeat('b',64));
|
|
|
|
|
select * from t1;
|
|
|
|
|
a
|
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
|
b
|
|
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
|
|
|
select * from t1 where a='b';
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
update t1 set a='bb' where a='b';
|
|
|
|
|
delete from t1 where a='bb';
|
|
|
|
|
select * from t1;
|
|
|
|
|
a
|
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
|
|
|
drop table t1;
|
|
|
|
|
create table t2 (a char(255) not null, primary key(a)) engine='MyISAM'
|
|
|
|
|
partition by key (a) partitions 27;
|
|
|
|
|
show create table t2;
|
|
|
|
|
Table Create Table
|
|
|
|
|
t2 CREATE TABLE `t2` (
|
|
|
|
|
`a` char(255) NOT NULL,
|
|
|
|
|
PRIMARY KEY (`a`)
|
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 27 */
|
|
|
|
|
26 inserts;
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+0),26+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+1),25+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+2),24+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+3),23+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+4),22+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+5),21+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+6),20+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+7),19+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+8),18+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+9),17+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+10),16+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+11),15+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+12),14+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+13),13+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+14),12+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+15),11+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+16),10+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+17),9+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+18),8+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+19),7+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+20),6+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+21),5+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+22),4+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+23),3+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+24),2+54));
|
|
|
|
|
insert into t2 values (repeat(char(ascii('a')+25),1+54));
|
|
|
|
|
select count(*) from t2;
|
|
|
|
|
count(*)
|
|
|
|
|
26
|
|
|
|
|
select * from t2;
|
|
|
|
|
a
|
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
|
|
|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
|
|
|
|
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
|
|
|
|
|
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
|
|
|
|
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
|
|
|
gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
|
|
|
|
|
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
|
|
|
|
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
|
|
|
|
|
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
|
|
|
|
|
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
|
|
|
|
|
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
|
|
|
|
|
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
|
|
|
|
|
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
|
|
|
|
|
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
|
|
|
|
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
|
|
|
|
|
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
|
|
|
|
|
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
|
|
|
|
|
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
|
|
|
|
ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
|
|
|
|
|
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
|
|
|
|
|
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
|
|
|
|
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
|
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
|
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
|
|
|
|
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
|
|
|
|
|
drop table t2;
|
|
|
|
|
---- Partitioning and binary data type
|
|
|
|
|
create table t1 (a binary(255) not null, primary key(a)) engine='MyISAM'
|
|
|
|
|
partition by key (a) (
|
2008-02-06 15:13:56 +01:00
|
|
|
|
partition pa1 max_rows=20 min_rows=2,
|
|
|
|
|
partition pa2 max_rows=30 min_rows=3,
|
|
|
|
|
partition pa3 max_rows=30 min_rows=4,
|
|
|
|
|
partition pa4 max_rows=40 min_rows=2);
|
2007-11-20 16:04:07 +01:00
|
|
|
|
show create table t1;
|
|
|
|
|
Table Create Table
|
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
|
`a` binary(255) NOT NULL,
|
|
|
|
|
PRIMARY KEY (`a`)
|
2008-02-06 15:13:56 +01:00
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
|
2007-11-20 16:04:07 +01:00
|
|
|
|
insert into t1 values (repeat('a',255)), ('b'), (repeat('a',128)), (repeat('b',64));
|
|
|
|
|
select hex(a) from t1;
|
|
|
|
|
hex(a)
|
|
|
|
|
616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
|
616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161
|
|
|
|
|
620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
|
626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
|
select a from t1 where substr(a,1,2)='b\0';
|
|
|
|
|
a
|
|
|
|
|
b |