postgresql 分区表

标题

postgresql 分区表

传统的分区表创建比较繁琐,涉及到触发器,继承,触发器函数等,维护相对困难,postgresql10之后支持内置的分区表。

1创建父表
create table test (id int4,times timestamp(0),name text)
partition by range(times)
根据times字段的范围进行分区

2 创建子表

create table test_sun partition of test for values from (‘2017-8-19’) to (‘2017-9-19’)

其中partition of后接表名为父表名称

3 创建索引

create index index1 on test_sun using btree(times)

4插入数据测试

insert into test (id,times,name) values(1,‘2017-8-19’,‘1’),(1,‘2017-8-21’,‘1’),(1,‘2017-8-22’,‘1’),(1,‘2017-8-23’,‘1’)

猜你喜欢

转载自blog.csdn.net/weixin_43632687/article/details/90199280