MySQL 按范围分区 - 语句错误?

MySQL partitioning by range - error in statement?

我尝试通过添加分区来更改现有的 table,但出现 SQL 错误,尽管它看起来像 docu 所说的。

希望有人能指出我的错误。

table 个订单有一个名为 date_order_start 的字段,它是 DATE,因此它没有时间信息。这个字段有一个索引。该索引不是唯一的,也不是另一个唯一索引的一部分。

我想使用以下语句对我的 table 进行分区:

ALTER TABLE orders
PARTITION BY RANGE (date_order_start) (
    startpoint   VALUES LESS THAN (0),
    from20140701 VALUES LESS THAN ('2014-07-01'),
    from20140801 VALUES LESS THAN ('2014-08-01'),
    from20140901 VALUES LESS THAN ('2014-09-01'),
    future       VALUES LESS THAN MAXVALUE
);

错误....

在我尝试之前:

ALTER TABLE orders
PARTITION BY RANGE (TO_DAYS(date_order_start)) (
    startpoint   VALUES LESS THAN (0),
    from20140701 VALUES LESS THAN (TO_DAYS('2014-07-01')),
    from20140801 VALUES LESS THAN (TO_DAYS('2014-08-01')),
    from20140901 VALUES LESS THAN (TO_DAYS('2014-09-01')),
    future       VALUES LESS THAN MAXVALUE
);

但也出现错误:

**Error Code: 1064**. 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 'from20140701 VALUES LESS THAN ('2014-07-01'), from20140801 VALUES LESS T' at line 4

嗯....那没用。

有人能找出错误吗?

没有起点语句的变体也不起作用。我以为 (0) 可能是问题所在。

我使用这些页面来获取信息:

http://dev.mysql.com/tech-resources/articles/mysql_55_partitioning.html http://dev.mysql.com/doc/refman/5.5/en/alter-table-partition-operations.html

我想知道您是否只是缺少分区关键字:

ALTER TABLE orders PARTITION BY RANGE (date_order_start) ( PARTITION startpoint VALUES LESS THAN (0), PARTITION from20140701 VALUES LESS THAN ('2014-07-01'), PARTITION from20140801 VALUES LESS THAN ('2014-08-01'), PARTITION from20140901 VALUES LESS THAN ('2014-09-01'), PARTITION future VALUES LESS THAN MAXVALUE );

此外,VALUES LESS THAN (0) 部分真的有必要吗?