PostgreSQL创建分表

先创建分表

create table tbl_partition_201712 (
check ( report_time >= DATE '2017-12-01' AND report_time < DATE '2017-12-31' )  
) INHERITS (passenger_flow);

通过建立规则的方式进行分区。这里以日期作为分隔的依据

CREATE RULE insert_tbl_partition_201211 AS ON INSERT TO passenger_flow WHERE     ( report_time >= DATE '2017-12-01' AND report_time < DATE '2017-12-31' ) DO INSTEAD     INSERT INTO tbl_partition_201712 VALUES (NEW.*);

相关文章
相关标签/搜索