错误原因:常量、随机或者依赖时区的表达式不能作为分区函数。
解决方法:把ts列换成datetime类型,创建成功。
CREATE TABLE T_log( id INT(11) NOT NULL AUTO_INCREMENT, zoneid INT(11) NOT NULL, numcount INT(11) NOT NULL, ts DATETIME NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id,ts) ) PARTITION BY RANGE (YEARWEEK(ts)) ( PARTITION p1 VALUES LESS THAN (201401), PARTITION p2 VALUES LESS THAN (201402), PARTITION p3 VALUES LESS THAN (201403), PARTITION p51 VALUES LESS THAN (201452), PARTITION p52 VALUES LESS THAN MAXVALUE));