2009-09-15 17:27:10 +02:00
|
|
|
drop table if exists t1;
|
2009-10-28 01:11:17 +01:00
|
|
|
create table t1 (a varchar(1500), b varchar(1570))
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a,b)
|
2009-10-28 01:11:17 +01:00
|
|
|
( partition p0 values in (('a','b')));
|
|
|
|
ERROR HY000: The total length of the partitioning fields is too large
|
|
|
|
create table t1 (a varchar(1023) character set utf8 collate utf8_spanish2_ci)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a)
|
2009-10-28 01:11:17 +01:00
|
|
|
( partition p0 values less than ('CZ'),
|
|
|
|
partition p1 values less than ('CH'),
|
|
|
|
partition p2 values less than ('D'));
|
|
|
|
insert into t1 values ('czz'),('chi'),('ci'),('cg');
|
|
|
|
select * from t1 where a between 'cg' AND 'ci';
|
|
|
|
a
|
|
|
|
ci
|
|
|
|
cg
|
|
|
|
drop table t1;
|
2009-10-28 00:06:11 +01:00
|
|
|
set @@sql_mode=allow_invalid_dates;
|
|
|
|
create table t1 (a char, b char, c date)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns (a,b,c)
|
2009-10-28 00:06:11 +01:00
|
|
|
( partition p0 values less than (0,0,to_days('3000-11-31')));
|
|
|
|
ERROR HY000: Partition column values of incorrect type
|
|
|
|
create table t1 (a char, b char, c date)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns (a,b,c)
|
2009-10-28 00:06:11 +01:00
|
|
|
( partition p0 values less than (0,0,'3000-11-31'));
|
|
|
|
ERROR HY000: Partition column values of incorrect type
|
|
|
|
set @@sql_mode='';
|
2009-10-22 18:17:59 +02:00
|
|
|
create table t1 (a varchar(2) character set ucs2)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns (a)
|
2009-10-22 18:17:59 +02:00
|
|
|
(partition p0 values in (0x2020),
|
|
|
|
partition p1 values in (''));
|
|
|
|
insert into t1 values ('');
|
|
|
|
insert into t1 values (_ucs2 0x2020);
|
|
|
|
drop table t1;
|
2009-10-22 16:15:06 +02:00
|
|
|
create table t1 (a int, b char(10), c varchar(25), d datetime)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b,c,d)
|
2009-10-22 16:15:06 +02:00
|
|
|
subpartition by hash (to_seconds(d))
|
|
|
|
subpartitions 4
|
2009-10-28 19:20:32 +01:00
|
|
|
( partition p0 values less than (1, 0, MAXVALUE, '1900-01-01'),
|
|
|
|
partition p1 values less than (1, 'a', MAXVALUE, '1999-01-01'),
|
2009-10-22 16:15:06 +02:00
|
|
|
partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
|
|
|
|
partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
|
|
|
|
select partition_method, partition_expression, partition_description
|
|
|
|
from information_schema.partitions where table_name = "t1";
|
|
|
|
partition_method partition_expression partition_description
|
2009-10-29 18:04:23 +01:00
|
|
|
RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'0',MAXVALUE,'1900-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,'1999-01-01'
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
|
|
|
RANGE COLUMNS a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
|
|
|
RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
|
|
|
RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
|
|
|
RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
|
|
|
RANGE COLUMNS a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
2009-10-22 18:17:59 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL,
|
|
|
|
`b` char(10) DEFAULT NULL,
|
|
|
|
`c` varchar(25) DEFAULT NULL,
|
|
|
|
`d` datetime DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2009-10-29 18:04:23 +01:00
|
|
|
/*!50100 PARTITION BY RANGE COLUMNS(a,b,c,d)
|
2009-10-22 18:17:59 +02:00
|
|
|
SUBPARTITION BY HASH (to_seconds(d))
|
|
|
|
SUBPARTITIONS 4
|
2009-10-30 21:08:34 +01:00
|
|
|
(PARTITION p0 VALUES LESS THAN (1,'0',MAXVALUE,'1900-01-01') ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES LESS THAN (1,'a',MAXVALUE,'1999-01-01') ENGINE = MyISAM,
|
|
|
|
PARTITION p2 VALUES LESS THAN (1,'a',MAXVALUE,MAXVALUE) ENGINE = MyISAM,
|
2009-10-22 18:17:59 +02:00
|
|
|
PARTITION p3 VALUES LESS THAN (1,MAXVALUE,MAXVALUE,MAXVALUE) ENGINE = MyISAM) */
|
2009-10-22 16:15:06 +02:00
|
|
|
drop table t1;
|
2009-10-06 17:01:59 +02:00
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns (a,b)
|
2009-10-21 20:53:44 +02:00
|
|
|
(partition p0 values less than (NULL, maxvalue));
|
|
|
|
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a,b)
|
2009-10-21 20:53:44 +02:00
|
|
|
( partition p0 values in ((maxvalue, 0)));
|
|
|
|
Got one of the listed errors
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns (a,b)
|
2009-10-22 16:15:06 +02:00
|
|
|
( partition p0 values in ((0,0)));
|
|
|
|
alter table t1 add partition
|
|
|
|
(partition p1 values in (maxvalue, maxvalue));
|
|
|
|
Got one of the listed errors
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int, b int)
|
2009-10-06 17:01:59 +02:00
|
|
|
partition by key (a,a);
|
2009-10-22 16:15:06 +02:00
|
|
|
ERROR HY000: Duplicate partition field name 'a'
|
2009-10-06 17:01:59 +02:00
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a,a)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p values in ((1,1)));
|
2009-10-22 16:15:06 +02:00
|
|
|
ERROR HY000: Duplicate partition field name 'a'
|
2009-10-06 16:22:15 +02:00
|
|
|
create table t1 (a int signed)
|
2009-10-06 16:22:54 +02:00
|
|
|
partition by list (a)
|
|
|
|
( partition p0 values in (1, 3, 5, 7, 9, NULL),
|
|
|
|
partition p1 values in (2, 4, 6, 8, 0));
|
|
|
|
insert into t1 values (NULL),(0),(1),(2),(2),(4),(4),(4),(8),(8);
|
|
|
|
select * from t1 where NULL <= a;
|
|
|
|
a
|
|
|
|
select * from t1 where a is null;
|
|
|
|
a
|
|
|
|
NULL
|
|
|
|
explain partitions select * from t1 where a is null;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where
|
|
|
|
select * from t1 where a <= 1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
0
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int signed)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values in (1, 3, 5, 7, 9, NULL),
|
|
|
|
partition p1 values in (2, 4, 6, 8, 0));
|
2009-10-06 16:22:15 +02:00
|
|
|
insert into t1 values (NULL),(0),(1),(2),(2),(4),(4),(4),(8),(8);
|
2009-10-06 16:22:54 +02:00
|
|
|
select * from t1 where a <= NULL;
|
|
|
|
a
|
|
|
|
select * from t1 where a is null;
|
|
|
|
a
|
|
|
|
NULL
|
|
|
|
explain partitions select * from t1 where a is null;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 Using where
|
2009-10-06 16:22:15 +02:00
|
|
|
select * from t1 where a <= 1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
0
|
|
|
|
drop table t1;
|
2009-10-01 16:50:11 +02:00
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a,b)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values in ((1, NULL), (2, NULL), (NULL, NULL)),
|
|
|
|
partition p1 values in ((1,1), (2,2)),
|
|
|
|
partition p2 values in ((3, NULL), (NULL, 1)));
|
2009-10-21 20:04:34 +02:00
|
|
|
select partition_method, partition_expression, partition_description
|
|
|
|
from information_schema.partitions where table_name = "t1";
|
|
|
|
partition_method partition_expression partition_description
|
2009-10-29 18:04:23 +01:00
|
|
|
LIST COLUMNS a,b (1,NULL),(2,NULL),(NULL,NULL)
|
|
|
|
LIST COLUMNS a,b (1,1),(2,2)
|
|
|
|
LIST COLUMNS a,b (3,NULL),(NULL,1)
|
2009-10-22 16:15:06 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL,
|
|
|
|
`b` int(11) DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2009-10-29 18:04:23 +01:00
|
|
|
/*!50100 PARTITION BY LIST COLUMNS(a,b)
|
2009-10-22 16:15:06 +02:00
|
|
|
(PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM,
|
|
|
|
PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */
|
2009-10-01 16:50:11 +02:00
|
|
|
insert into t1 values (3, NULL);
|
|
|
|
insert into t1 values (NULL, 1);
|
|
|
|
insert into t1 values (NULL, NULL);
|
|
|
|
insert into t1 values (1, NULL);
|
|
|
|
insert into t1 values (2, NULL);
|
|
|
|
insert into t1 values (1,1);
|
|
|
|
insert into t1 values (2,2);
|
|
|
|
select * from t1 where a = 1;
|
|
|
|
a b
|
|
|
|
1 NULL
|
|
|
|
1 1
|
|
|
|
select * from t1 where a = 2;
|
|
|
|
a b
|
|
|
|
2 NULL
|
|
|
|
2 2
|
2009-10-02 11:31:05 +02:00
|
|
|
select * from t1 where a > 8;
|
|
|
|
a b
|
|
|
|
select * from t1 where a not between 8 and 8;
|
|
|
|
a b
|
|
|
|
2 NULL
|
|
|
|
2 2
|
|
|
|
3 NULL
|
|
|
|
1 NULL
|
|
|
|
1 1
|
2009-10-01 16:50:11 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL,
|
|
|
|
`b` int(11) DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2009-10-29 18:04:23 +01:00
|
|
|
/*!50100 PARTITION BY LIST COLUMNS(a,b)
|
2009-10-21 12:40:21 +02:00
|
|
|
(PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM,
|
|
|
|
PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */
|
2009-10-01 16:50:11 +02:00
|
|
|
drop table t1;
|
2009-10-01 15:04:42 +02:00
|
|
|
create table t1 (a int)
|
|
|
|
partition by list (a)
|
|
|
|
( partition p0 values in (1),
|
|
|
|
partition p1 values in (1));
|
|
|
|
ERROR HY000: Multiple definition of same constant in list partitioning
|
|
|
|
create table t1 (a int)
|
|
|
|
partition by list (a)
|
|
|
|
( partition p0 values in (2, 1),
|
|
|
|
partition p1 values in (4, NULL, 3));
|
2009-10-21 20:04:34 +02:00
|
|
|
select partition_method, partition_expression, partition_description
|
|
|
|
from information_schema.partitions where table_name = "t1";
|
|
|
|
partition_method partition_expression partition_description
|
|
|
|
LIST a 2,1
|
|
|
|
LIST a NULL,4,3
|
2009-10-22 16:15:06 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
|
|
/*!50100 PARTITION BY LIST (a)
|
|
|
|
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES IN (NULL,4,3) ENGINE = MyISAM) */
|
2009-10-01 15:04:42 +02:00
|
|
|
insert into t1 values (1);
|
|
|
|
insert into t1 values (2);
|
|
|
|
insert into t1 values (3);
|
|
|
|
insert into t1 values (4);
|
|
|
|
insert into t1 values (NULL);
|
|
|
|
insert into t1 values (5);
|
|
|
|
ERROR HY000: Table has no partition for value 5
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values in (2, 1),
|
|
|
|
partition p1 values in ((4), (NULL), (3)));
|
|
|
|
ERROR 42000: Row expressions in VALUES IN only allowed for multi-field column partitioning near '))' at line 4
|
|
|
|
create table t1 (a int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values in (2, 1),
|
|
|
|
partition p1 values in (4, NULL, 3));
|
2009-10-21 20:04:34 +02:00
|
|
|
select partition_method, partition_expression, partition_description
|
|
|
|
from information_schema.partitions where table_name = "t1";
|
|
|
|
partition_method partition_expression partition_description
|
2009-10-29 18:04:23 +01:00
|
|
|
LIST COLUMNS a 2,1
|
|
|
|
LIST COLUMNS a 4,NULL,3
|
2009-10-22 16:15:06 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2009-10-29 18:04:23 +01:00
|
|
|
/*!50100 PARTITION BY LIST COLUMNS(a)
|
2009-10-22 16:15:06 +02:00
|
|
|
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */
|
2009-10-01 15:04:42 +02:00
|
|
|
insert into t1 values (1);
|
|
|
|
insert into t1 values (2);
|
|
|
|
insert into t1 values (3);
|
|
|
|
insert into t1 values (4);
|
|
|
|
insert into t1 values (NULL);
|
|
|
|
insert into t1 values (5);
|
|
|
|
ERROR HY000: Table has no partition for value from column_list
|
2009-10-01 16:50:11 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2009-10-29 18:04:23 +01:00
|
|
|
/*!50100 PARTITION BY LIST COLUMNS(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */
|
2009-10-01 15:04:42 +02:00
|
|
|
drop table t1;
|
2009-09-15 17:27:10 +02:00
|
|
|
create table t1 (a int, b char(10), c varchar(5), d int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b,c)
|
2009-09-15 17:27:10 +02:00
|
|
|
subpartition by key (c,d)
|
|
|
|
subpartitions 3
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values less than (1,'abc','abc'),
|
|
|
|
partition p1 values less than (2,'abc','abc'),
|
|
|
|
partition p2 values less than (3,'abc','abc'),
|
|
|
|
partition p3 values less than (4,'abc','abc'));
|
2009-10-21 20:04:34 +02:00
|
|
|
select partition_method, partition_expression, partition_description
|
|
|
|
from information_schema.partitions where table_name = "t1";
|
|
|
|
partition_method partition_expression partition_description
|
2009-10-29 18:04:23 +01:00
|
|
|
RANGE COLUMNS a,b,c 1,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 1,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 1,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 2,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 2,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 2,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 3,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 3,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 3,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 4,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 4,'abc','abc'
|
|
|
|
RANGE COLUMNS a,b,c 4,'abc','abc'
|
2009-10-22 16:15:06 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL,
|
|
|
|
`b` char(10) DEFAULT NULL,
|
|
|
|
`c` varchar(5) DEFAULT NULL,
|
|
|
|
`d` int(11) DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2009-10-29 18:04:23 +01:00
|
|
|
/*!50100 PARTITION BY RANGE COLUMNS(a,b,c)
|
2009-10-22 16:15:06 +02:00
|
|
|
SUBPARTITION BY KEY (c,d)
|
|
|
|
SUBPARTITIONS 3
|
2009-10-30 21:08:34 +01:00
|
|
|
(PARTITION p0 VALUES LESS THAN (1,'abc','abc') ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES LESS THAN (2,'abc','abc') ENGINE = MyISAM,
|
|
|
|
PARTITION p2 VALUES LESS THAN (3,'abc','abc') ENGINE = MyISAM,
|
|
|
|
PARTITION p3 VALUES LESS THAN (4,'abc','abc') ENGINE = MyISAM) */
|
2009-09-15 17:27:10 +02:00
|
|
|
insert into t1 values (1,'a','b',1),(2,'a','b',2),(3,'a','b',3);
|
|
|
|
insert into t1 values (1,'b','c',1),(2,'b','c',2),(3,'b','c',3);
|
|
|
|
insert into t1 values (1,'c','d',1),(2,'c','d',2),(3,'c','d',3);
|
|
|
|
insert into t1 values (1,'d','e',1),(2,'d','e',2),(3,'d','e',3);
|
|
|
|
select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) OR
|
|
|
|
(a = 1 AND b >= 'a' AND (c = 'c' OR (c = 'd' AND d = 2))));
|
|
|
|
a b c d
|
|
|
|
1 a b 1
|
|
|
|
1 b c 1
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int, b varchar(2), c int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns (a, b, c)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values less than (1, 'A', 1),
|
|
|
|
partition p1 values less than (1, 'B', 1));
|
2009-10-21 20:04:34 +02:00
|
|
|
select partition_method, partition_expression, partition_description
|
|
|
|
from information_schema.partitions where table_name = "t1";
|
|
|
|
partition_method partition_expression partition_description
|
2009-10-29 18:04:23 +01:00
|
|
|
RANGE COLUMNS a,b,c 1,'A',1
|
|
|
|
RANGE COLUMNS a,b,c 1,'B',1
|
2009-10-22 16:15:06 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL,
|
|
|
|
`b` varchar(2) DEFAULT NULL,
|
|
|
|
`c` int(11) DEFAULT NULL
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2009-10-29 18:04:23 +01:00
|
|
|
/*!50100 PARTITION BY RANGE COLUMNS(a,b,c)
|
2009-10-30 21:08:34 +01:00
|
|
|
(PARTITION p0 VALUES LESS THAN (1,'A',1) ENGINE = MyISAM,
|
|
|
|
PARTITION p1 VALUES LESS THAN (1,'B',1) ENGINE = MyISAM) */
|
2009-09-15 17:27:10 +02:00
|
|
|
insert into t1 values (1, 'A', 1);
|
|
|
|
explain partitions select * from t1 where a = 1 AND b <= 'A' and c = 1;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 p0,p1 system NULL NULL NULL NULL 1
|
|
|
|
select * from t1 where a = 1 AND b <= 'A' and c = 1;
|
|
|
|
a b c
|
|
|
|
1 A 1
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a char, b char, c char)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values in ('a'));
|
2009-09-15 17:27:10 +02:00
|
|
|
insert into t1 (a) values ('a');
|
|
|
|
select * from t1 where a = 'a';
|
|
|
|
a b c
|
|
|
|
a NULL NULL
|
|
|
|
drop table t1;
|
2009-10-22 16:15:06 +02:00
|
|
|
create table t1 (d time)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(d)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values less than ('2000-01-01'),
|
|
|
|
partition p1 values less than ('2040-01-01'));
|
2009-09-15 17:27:10 +02:00
|
|
|
ERROR HY000: Partition column values of incorrect type
|
2009-10-22 16:15:06 +02:00
|
|
|
create table t1 (d timestamp)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(d)
|
2009-10-22 16:15:06 +02:00
|
|
|
( partition p0 values less than ('2000-01-01'),
|
|
|
|
partition p1 values less than ('2040-01-01'));
|
|
|
|
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
|
|
|
|
create table t1 (d bit(1))
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(d)
|
2009-10-22 16:15:06 +02:00
|
|
|
( partition p0 values less than (0),
|
|
|
|
partition p1 values less than (1));
|
|
|
|
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
|
2009-09-15 17:27:10 +02:00
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b)
|
2009-10-21 20:53:44 +02:00
|
|
|
(partition p0 values less than (maxvalue, 10));
|
2009-09-15 17:27:10 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (d date)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(d)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values less than ('2000-01-01'),
|
|
|
|
partition p1 values less than ('2009-01-01'));
|
2009-09-15 17:27:10 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (d date)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(d)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values less than ('1999-01-01'),
|
|
|
|
partition p1 values less than ('2000-01-01'));
|
2009-09-15 17:27:10 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (d date)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(d)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values less than ('2000-01-01'),
|
|
|
|
partition p1 values less than ('3000-01-01'));
|
2009-09-15 17:27:10 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p2 values less than (99,99),
|
|
|
|
partition p1 values less than (99,999));
|
2009-09-15 17:27:10 +02:00
|
|
|
insert into t1 values (99,998);
|
|
|
|
select * from t1 where b = 998;
|
|
|
|
a b
|
|
|
|
99 998
|
|
|
|
drop table t1;
|
|
|
|
create table t1 as select to_seconds(null) as to_seconds;
|
|
|
|
select data_type from information_schema.columns
|
|
|
|
where column_name='to_seconds';
|
|
|
|
data_type
|
|
|
|
int
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a,b)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values in ((maxvalue,maxvalue)));
|
2009-10-21 20:53:44 +02:00
|
|
|
ERROR 42000: Cannot use MAXVALUE as value in VALUES IN near 'maxvalue,maxvalue)))' at line 3
|
2009-09-15 17:27:10 +02:00
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values less than (maxvalue,maxvalue));
|
2009-09-15 17:27:10 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values in (0));
|
2009-09-15 17:27:10 +02:00
|
|
|
select partition_method from information_schema.partitions where table_name='t1';
|
|
|
|
partition_method
|
2009-10-29 18:04:23 +01:00
|
|
|
LIST COLUMNS
|
2009-09-15 17:27:10 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (a char(6))
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values less than ('H23456'),
|
|
|
|
partition p1 values less than ('M23456'));
|
2009-09-15 17:27:10 +02:00
|
|
|
insert into t1 values ('F23456');
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
F23456
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a char(6))
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values less than (H23456),
|
|
|
|
partition p1 values less than (M23456));
|
2009-09-15 17:27:10 +02:00
|
|
|
ERROR 42S22: Unknown column 'H23456' in 'field list'
|
|
|
|
create table t1 (a char(6))
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values less than (23456),
|
|
|
|
partition p1 values less than (23456));
|
2009-09-15 17:27:10 +02:00
|
|
|
ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b)
|
2009-09-15 17:27:10 +02:00
|
|
|
(partition p0 values less than (10));
|
|
|
|
ERROR 42000: Inconsistency in usage of column lists for partitioning near '))' at line 3
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values less than (1,1,1);
|
2009-09-15 17:27:10 +02:00
|
|
|
ERROR HY000: Inconsistency in usage of column lists for partitioning
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b)
|
2009-10-21 20:53:44 +02:00
|
|
|
(partition p0 values less than (1, 0),
|
2009-10-21 12:40:21 +02:00
|
|
|
partition p1 values less than (2, maxvalue),
|
|
|
|
partition p2 values less than (3, 3),
|
2009-10-21 20:53:44 +02:00
|
|
|
partition p3 values less than (10, maxvalue));
|
|
|
|
insert into t1 values (11,0);
|
2009-09-15 17:27:10 +02:00
|
|
|
ERROR HY000: Table has no partition for value from column_list
|
|
|
|
insert into t1 values (0,1),(1,1),(2,1),(3,1),(3,4),(4,9),(9,1);
|
|
|
|
select * from t1;
|
|
|
|
a b
|
|
|
|
0 1
|
|
|
|
1 1
|
|
|
|
2 1
|
|
|
|
3 1
|
|
|
|
3 4
|
|
|
|
4 9
|
|
|
|
9 1
|
|
|
|
alter table t1
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(b,a)
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values less than (1,2),
|
|
|
|
partition p1 values less than (3,3),
|
|
|
|
partition p2 values less than (9,5));
|
2009-09-15 17:27:10 +02:00
|
|
|
explain partitions select * from t1 where b < 2;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 7 Using where
|
|
|
|
select * from t1 where b < 2;
|
|
|
|
a b
|
|
|
|
0 1
|
|
|
|
1 1
|
|
|
|
2 1
|
|
|
|
3 1
|
|
|
|
9 1
|
|
|
|
explain partitions select * from t1 where b < 4;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 p0,p1,p2 ALL NULL NULL NULL NULL 7 Using where
|
|
|
|
select * from t1 where b < 4;
|
|
|
|
a b
|
|
|
|
0 1
|
|
|
|
1 1
|
|
|
|
2 1
|
|
|
|
3 1
|
|
|
|
9 1
|
|
|
|
alter table t1 reorganize partition p1 into
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p11 values less than (2,2),
|
|
|
|
partition p12 values less than (3,3));
|
2009-09-15 17:27:10 +02:00
|
|
|
alter table t1 reorganize partition p0 into
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p01 values less than (0,3),
|
|
|
|
partition p02 values less than (1,1));
|
2009-09-15 17:27:10 +02:00
|
|
|
ERROR HY000: Reorganize of range partitions cannot change total ranges except for last partition where it can extend the range
|
|
|
|
alter table t1 reorganize partition p2 into
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p2 values less than(9,6,1));
|
2009-09-15 17:27:10 +02:00
|
|
|
ERROR HY000: Inconsistency in usage of column lists for partitioning
|
|
|
|
alter table t1 reorganize partition p2 into
|
|
|
|
(partition p2 values less than (10));
|
|
|
|
ERROR HY000: Inconsistency in usage of column lists for partitioning
|
|
|
|
alter table t1 reorganize partition p2 into
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p21 values less than (4,7),
|
|
|
|
partition p22 values less than (9,5));
|
2009-09-15 17:27:10 +02:00
|
|
|
explain partitions select * from t1 where b < 4;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 p0,p11,p12,p21 ALL NULL NULL NULL NULL 7 Using where
|
|
|
|
select * from t1 where b < 4;
|
|
|
|
a b
|
|
|
|
0 1
|
|
|
|
1 1
|
|
|
|
2 1
|
|
|
|
3 1
|
|
|
|
9 1
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int, b int)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by list columns(a,b)
|
2009-09-15 17:27:10 +02:00
|
|
|
subpartition by hash (b)
|
|
|
|
subpartitions 2
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p0 values in ((0,0), (1,1)),
|
|
|
|
partition p1 values in ((1000,1000)));
|
2009-09-15 17:27:10 +02:00
|
|
|
insert into t1 values (1000,1000);
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a char, b char, c char)
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a,b,c)
|
2009-10-21 12:40:21 +02:00
|
|
|
( partition p0 values less than ('a','b','c'));
|
2009-09-15 17:27:10 +02:00
|
|
|
alter table t1 add partition
|
2009-10-21 12:40:21 +02:00
|
|
|
(partition p1 values less than ('b','c','d'));
|
2009-09-15 17:27:10 +02:00
|
|
|
drop table t1;
|