PolarDB支持官方的单表转分区表的语法:
ALTER TABLE ... PARTITION BY...
举例如下:
1. 普通表转RANGE分区表
alter table t1 partition by range(a) (
partition p0 values less than (100),
partition p1 values less than (200)
);
2. 普通表转HASH分区表
alter table t1 partition by hash(a) partitions 12;
3. 普通表转LIST DEFAULT HASH分区表
alter table t1 partition by LIST(a)
(PARTITION p0 VALUES IN (1,2,3,4,5),
PARTITION p1 VALUES IN (6,7,8,9,10),
PARTITION pd DEFAULT PARTITIONS 9);