partition访问子分区

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
postgres=# create table t_native_range (f1 bigint,f2 timestamp default now(), f3 integer) partition by range ( f2 ) distribute by shard(f1) to group default_group; 
CREATE TABLE
postgres=# create table t_native_range_201709 partition of t_native_range  for values from ('2017-09-01') to ('2017-10-01');              
CREATE TABLE
postgres=# create table t_native_range_201710 partition of t_native_range  for values from ('2017-10-01') to ('2017-11-01');              
CREATE TABLE
postgres=# insert into t_native_range values(1,'2017-09-01',1);
INSERT 0 1
postgres=# insert into t_native_range values(2,'2017-09-01',2);
INSERT 0 1
postgres=# select * from t_native_range partition(t_native_range_201709);
 f1 |         f2          | f3 
----+---------------------+----
  1 | 2017-09-01 00:00:00 |  1
  2 | 2017-09-01 00:00:00 |  2
(2 rows)
postgres=#