在MySQL中,创建带分区的表一切正常,如下:
create table t1 (
id int,
year_col int
)
partition by range (year_col) (
partition p0 values less than (1991),
partition p0 values less than (1995),
partition p0 values less than (1999)
);
但是创建完成之后,再想新增加一个分区p3,如下:
alter table t1 add partition p3 values less than (2002);
就会报如下错误:
ERROR 1064 (42000): 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 'p3 values less than (2002)' at line 1
这个例子是MySQL官网上的,请明白的人帮忙解决下这个问题。

解决方案 »

  1.   

    你看的手册或者例子显然有问题。建议直接参考 ALTER TABLE 的语法。mysql> create table t1 (
        -> id int,
        -> year_col int
        -> )
        -> partition by range (year_col) (
        -> partition p0 values less than (1991),
        -> partition p1 values less than (1995),
        -> partition p2 values less than (1999)
        -> );
    Query OK, 0 rows affected (0.03 sec)mysql>
    mysql> alter table t1 add partition (PARTITION p3 values less than (2002));
    Query OK, 0 rows affected (0.08 sec)
    Records: 0  Duplicates: 0  Warnings: 0mysql>
      

  2.   

    我看的是MySQL官方网站上的中文参考,刚才对照了一下官方的英文参考,的确是例子的原因,多谢 
    ACMAIN_CHM啦!!!