How to partition postgres table using intermediate table

后端 未结 2 769
一向
一向 2020-12-12 05:41

I am using postgres 10 db.

I am having Customers table consisting of following columns

custid (primary key),
name,
phonenumber,
email,
dateofbirth,
a         


        
2条回答
  •  时光说笑
    2020-12-12 06:33

    Try this method:

    1. First of all, create an additional column in customer table as you want to logical partition.
    2. Then update that columns using customer and intermediate table
    3. After updating truncate your table

    For each month you can run this script and this will give you logical partitioning.

    update customer set partition_column=to_char(Join_Date, 'YYYY-MM')
    join intermediate_table on intermediate_table.custid=customer.custid
    and  intermediate_table.Join_Date=customer.Join_Date
    
    truncate table intermediate_table
    

提交回复
热议问题