PG分区表

标签: PG  pg分区表  PG分区表种类  postgres分区

PG-分区


在这里插入图片描述

建分区表语句:

PG版本为: PostgreSQL 11.8

声明式分区表(推荐):

  • 创建表时并 指定分区字段 为logdate
CREATE TABLE measurement (
    city_id         int not null,
    logdate         date not null,
    peaktemp        int,
    unitsales       int
) PARTITION BY RANGE (logdate);
  • 创建两个分区表 measurement_y2020m09measurement_y2020m09
CREATE TABLE measurement_y2020m09 PARTITION OF measurement
    FOR VALUES FROM ('2020-09-01') TO ('2020-10-01');

CREATE TABLE measurement_y2020m09 PARTITION OF measurement
    FOR VALUES FROM ('2020-10-01') TO ('2020-11-01');
版权声明:本文为RONE321原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/RONE321/article/details/108381815