希望非常简单,可能很明显,但我的语法有什么问题。我整个上午一直在和这个摔跤。
我创建了一组分区:
ALTER TABLE `schemaName`.`tableName`
PARTITION BY RANGE (TO_DAYS(`Created`)) (
PARTITION `early` VALUES LESS THAN (TO_DAYS('2013-01-01 00:00:00')),
PARTITION `201301` VALUES LESS THAN (TO_DAYS('2013-02-01 00:00:00')),
PARTITION `201302` VALUES LESS THAN (TO_DAYS('2013-03-01 00:00:00')),
PARTITION `201303` VALUES LESS THAN (TO_DAYS('2013-04-01 00:00:00')),
PARTITION `201304` VALUES LESS THAN MAXVALUE
);
到目前为止,最后一个分区现在保存4月1日之后的任何数据(例如4月和5月)。
现在我想重新组织该分区(201304)以便它仅保存4月的数据,并将May的数据移动到新的“最后”分区。我的语法是:
ALTER TABLE `schemaName`.`tableName` REORGANIZE PARTITION `201304` INTO
(
`201304` VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00')),
`201305` VALUES LESS THAN MAXVALUE
);
但是我收到一个错误,表明问题出现在第一个定义(201304` VALUES LESS ...)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`201304` VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00')),
#-->ALL DATA BEFORE ' at line 3
如果有人能发现错误,我将非常感激。
答案 0 :(得分:6)
以互联网为例,我最终在一本旧书中找到了一个例子:
ALTER TABLE `schemaName`.`tableName` REORGANIZE PARTITION `201304` INTO
(
PARTITION `201304` VALUES LESS THAN (TO_DAYS('2013-05-01 00:00:00')),
PARTITION `201305` VALUES LESS THAN MAXVALUE
);