我创建了一个表:
create table mytest(
id int not null,
starttime timestamp,
primary key(id, starttime)
)
现在想根据周来分区,该怎么写???
如果想让它这样循环下去,又该怎么写,或者说可以自动添加分区
create table mytest(
id int not null,
starttime timestamp,
primary key(id, starttime)
)
现在想根据周来分区,该怎么写???
如果想让它这样循环下去,又该怎么写,或者说可以自动添加分区
partition BY range(to_days(starttime)) (
partition p_2010 VALUES LESS THAN (to_days('2011-01-01')),
partition p_201101 VALUES LESS THAN (to_days('2011-02-01')),
partition p_201102 VALUES LESS THAN (to_days('2011-03-01')),
partition p_201103 VALUES LESS THAN (to_days('2011-04-01')),
partition p_201104 VALUES LESS THAN (to_days('2011-05-01')),
partition p_201105 VALUES LESS THAN (to_days('2011-06-01')),
partition p_201106 VALUES LESS THAN (to_days('2011-07-01')),
partition p_201107 VALUES LESS THAN (to_days('2011-08-01')),
partition p_201108 VALUES LESS THAN (to_days('2011-09-01')),
partition p_201109 VALUES LESS THAN (to_days('2011-10-01')),
partition p_201110 VALUES LESS THAN (to_days('2011-11-01')),
partition p_201111 VALUES LESS THAN (to_days('2011-12-01')),
partition p_201112 VALUES LESS THAN (to_days('2012-01-01')),
partition p_2012 VALUES LESS THAN (to_days('2013-01-01')),
partition p_max VALUES LESS THAN (maxvalue) );
ERROR 1486: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
MySQL 5.5支持PARTITION BY RANGE ( UNIX_TIMESTAMP(starttime ) )