数据仓库服务 GAUSSDB(DWS)-执行表分区操作时,报错:start value of partition "xxx" NOT EQUAL up-boundary of last partition:解决办法

时间:2024-11-02 18:44:28

解决办法

为防止出现分区间隙,需要将ADD PARTITION的START值前移。

以分区表partitiontest为例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CREATE TABLE partitiontest 
( 
 c_int integer,
 c_time TIMESTAMP WITHOUT TIME ZONE
) 
PARTITION BY range (c_int) 
(
 partition p1 start(100)end(108), 
 partition p2 start(108)end(120) 
);  

执行如下两种语句会发生报错:

1
2
ALTER TABLE partitiontest ADD PARTITION p3 start(120)end(130), DROP PARTITION p2;
ERROR:  start value of partition "p3" NOT EQUAL up-boundary of last partition.
1
2
ALTER TABLE partitiontest DROP PARTITION p2,ADD PARTITION p3 start(120)end(130);
ERROR:  start value of partition "p3" NOT EQUAL up-boundary of last partition.

可以修改语句为:

1
ALTER TABLE partitiontest ADD PARTITION p3 start(108)end(130), DROP PARTITION p2;
1
ALTER TABLE partitiontest DROP PARTITION p2,ADD PARTITION p3 start(108)end(130);
support.huaweicloud.com/trouble-dws/dws_09_0022.html