范围分区表使用
最近更新时间: 2025-02-18 16:02:00
postgres=#create table t_range (f1 bigint,f2 timestamp default now(), f3 integer) partition by range (f3) begin (1) step (50) partitions (3) distribute by shard(f1) to group default_group;
CREATE TABLE
postgres=# insert into t_range(f1,f3) values(1,1),(2,50),(3,100),(2,110);
INSERT 0 4
#这样的语句执行会出错,提示超出范围
postgres=# insert into t_range(f1,f3) values(1,151);
ERROR: node:16385, error inserted value is not in range of partitioned table, please check the value of paritition key
#解决办法再扩展一些分区后就可以使用了
postgres=# ALTER TABLE t_range ADD PARTITIONS 2;
ALTER TABLE
postgres=# insert into t_range(f1,f3) values(1,151);
INSERT 0 1
postgres=#