表示按照日期 list 分区 ,下面这样:
create table p_test(
data_date date not null,
name varchar(20) not null,
age int not null
) partition by list(to_days(data_date))
(
partition p1 values in(to_days('2015-01-01'))
);
alter table p_test add CONSTRAINT pk_ptest primary key(data_date) ;只要查询where条件中有data_date过滤,就会 报Communications link failure错误,查询语句如下:
select * from p_test where data_date = date'2016-05-01'
create table p_test(
data_date date not null,
name varchar(20) not null,
age int not null
) partition by list(to_days(data_date))
(
partition p1 values in(to_days('2015-01-01'))
);
alter table p_test add CONSTRAINT pk_ptest primary key(data_date) ;只要查询where条件中有data_date过滤,就会 报Communications link failure错误,查询语句如下:
select * from p_test where data_date = date'2016-05-01'
我试了一下,不会报错,然后插入范围内的数据,也不会报错,如果插入了 不再list中的数据,就会报错:mysql> insert into p_test values('2015-01-01','xxx',10);
Query OK, 1 row affected (0.21 sec)mysql> select * from p_test where data_date = date'2016-05-01';
Empty set (0.00 sec)mysql> insert into p_test values(date'2015-05-01','xxx',10);
ERROR 1526 (HY000): Table has no partition for value 736084
我的是5.6.25的,也是没问题的,有可能是那个版本有bug :
mysql> select version();
+------------+
| version() |
+------------+
| 5.6.25-log |
+------------+
1 row in set (0.00 sec)