PHP Script to Generate PostgreSQL Table Partitioning (Part 2) - Comment Page: 1

As Part 1 (Howto create PostgreSQL table partitioning) shows, making of PostgreSQL partitioning needs a lot of SQL commands. So this Part 2 explains how SQL commands for PostgreSQL partitioning can be made with a simple PHP script. This example script make SQL for child tables, indexes, trigger function and parent table trigger. This example script can make PostgreSQL table partitioning with using Date ranges. Script can be configured with following configuration section: Initial parameters Set the parent table name: $parent_table_name = "impressions_by_day"; Set check field name (only one field can be used) $check_field = "day"; Set the start date where partitioning...

3 comments on “PHP Script to Generate PostgreSQL Table Partitioning (Part 2) - Comment Page: 1

    1. this post will help me a lot for my work in college.

      Reply
    2. Can we use with catch exception let say when undefined_table create newtableYEARMONTH will it work. so new inheritance table will be created automatically ?

      Reply
      • Hi Candra Nur Ihsan,

        Yes it should work, but it’s always good to test it properly. I think that you don’t want to lose any data when this situation occurs.

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close