如何使用中间表对postgres表进行分区 [英] How to partition postgres table using intermediate table

查看:177
本文介绍了如何使用中间表对postgres表进行分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用postgres 10 db。

I am using postgres 10 db.

我正在由以下几列组成的客户表

I am having Customers table consisting of following columns

custid (primary key),
name,
phonenumber,
email,
dateofbirth,
address,
city,
country,
status(boolean)
Join_Date(Date)

我表中有数百万条记录。我想通过Join_Date和Intermediate table在不同月份的基础上对表进行分区(2018年1月为一个分区,2018年2月为一个分区,等等)。

I have million of records in table. I want to partition table based on different months(Jan 2018 one partition, Feb 2018 one partition,..etc) by help of Join_Date and with help of Intermediate table.

我还想编写自动化脚本,以便在月底时该表必须创建上个月的另一个分区

I also want to write the automated script such that at the end of month the table have to get create another partition of last month

推荐答案

Postgres文档中有一个针对您问题的示例。

There is an example for your problem in the Postgres documentation.

PostgreSQL:文档:10:5.10。表分区

这篇关于如何使用中间表对postgres表进行分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆