问题现象
创建表时,如果有随表一起创建全局分区索引,则会报如下语法错误。
obclient > create table g1 (id int primary key, r1 int, key gdx_r1(r1) global partition by key(r1) partitions 10);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'partition by key(r1) partitions 10)' at line 1
问题原因
目前 OceanBase 数据库 V2.x 和 V3.x 版本都未支持建表时创建全局分区索引。
适用版本
OceanBase 数据库 V2.x 和 V3.x 版本。
解决方法
建表时不带全局分区索引,建表后再补上。
创建示例表。
obclient > create table g1 (id int primary key, r1 int); Query OK, 0 rows affected (0.105 sec)创建全局分区索引。
obclinet > create index gdx_r1 on g1(r1) global partition by key(r1) partitions 10; Query OK, 0 rows affected (3.452 sec)