• The partitioned table structure is uniform. Each partition node at the same level must have the same hierarchical structure.
    • The partition key constraints must be consistent and uniform. At each subpartition level, the sets of constraints on the child tables created for each branch must match.

    You can display information about partitioned tables in several ways, including displaying information from these sources:

    • The pg_partitions system view contains information on the structure of a partitioned table.
    • The pg_constraint system catalog table contains information on table constraints.
    • The psql meta command \d+ tablename displays the table constraints for child leaf tables of a partitioned table.

    Parent topic:

    This CREATE TABLE command creates a uniform partitioned table.

    These are child tables and the partition hierarchy that are created for the table mlp. This hierarchy consists of one subpartition level that contains two branches.

    1. mlp_1_prt_11
    2. mlp_1_prt_11_2_prt_usa
    3. mlp_1_prt_11_2_prt_europe
    4. mlp_1_prt_11_2_prt_asia
    5. mlp_1_prt_21_2_prt_usa
    6. mlp_1_prt_21_2_prt_europe
    7. mlp_1_prt_21_2_prt_asia

    As a quick check, this query displays the constraints for the partitions.

    The consrc column displays constraints on the subpartitions. The set of region constraints for the subpartitions in mlp_1_prt_1 match the constraints for the subpartitions in mlp_1_prt_2. The constraints for year are inherited from the parent branch tables.

    1. part | consrc
    2. --------------------------+------------------------------------
    3. mlp_1_prt_2_2_prt_asia | (region = 'asia'::text)
    4. mlp_1_prt_1_2_prt_asia | (region = 'asia'::text)
    5. mlp_1_prt_2_2_prt_europe | (region = 'europe'::text)
    6. mlp_1_prt_1_2_prt_europe | (region = 'europe'::text)
    7. mlp_1_prt_1_2_prt_usa | (region = 'usa'::text)
    8. mlp_1_prt_1_2_prt_asia | ((year >= 2006) AND (year < 2011))
    9. mlp_1_prt_1_2_prt_usa | ((year >= 2006) AND (year < 2011))
    10. mlp_1_prt_1_2_prt_europe | ((year >= 2006) AND (year < 2011))
    11. mlp_1_prt_2_2_prt_asia | ((year >= 2011) AND (year < 2016))
    12. mlp_1_prt_2_2_prt_europe | ((year >= 2011) AND (year < 2016))
    13. (12 rows)

    The partitioned table remains a uniform partitioned table. The branch created for default partition contains three child tables and the set of constraints on the child tables match the existing sets of child table constraints.

    In the above example, if you drop the subpartition mlp_1_prt_21_2_prt_asia and add another subpartition for the region canada, the constraints are no longer uniform.

    1. ALTER TABLE mlp ALTER PARTITION FOR (RANK(2))
    2. DROP PARTITION asia ;
    3. ADD PARTITION canada VALUES ('canada');

    Also, if you add a partition canada under mlp_1_prt_21, the partitioning hierarchy is not uniform.

    However, if you add the subpartition canada to both mlp_1_prt_21 and the of the original partitioned table, it remains a uniform partitioned table.

    Only the constraints on the sets of partitions at a partition level must be the same. The names of the partitions can be different.