Defining a MAXVALUE partition v17
A MAXVALUE
partition or subpartition captures any rows that don't fit into any other partition in a range-partitioned or subpartitioned table. If you don't include a MAXVALUE
rule, any row that exceeds the maximum limit specified by the partitioning rules causes in an error. Each partition or subpartition can have its own MAXVALUE
partition.
The syntax of a MAXVALUE
rule is:
Where partition_name
specifies the name of the partition that stores any rows that don't match the rules specified for other partitions.
This example created a range-partitioned table in which the data was partitioned based on the value of the date
column. If you attempt to add a row with a date
value that exceeds a date listed in the partitioning constraints, EDB Postgres Advanced Server reports an error.
This CREATE TABLE
command creates the same table but with a MAXVALUE
partition. Instead of throwing an error, the server stores any rows that don't match the previous partitioning constraints in the others
partition.
To test the MAXVALUE
partition, add a row with a value in the date
column that exceeds the last date value listed in a partitioning rule. The server stores the row in the others
partition.
Query the contents of the sales
table to confirm that the previously rejected row is now stored in the sales_others
partition:
EDB Postgres Advanced Server doesn't have a way to reassign the contents of a MAXVALUE
partition or subpartition.
- You can't use the
ALTER TABLE… ADD PARTITION
statement to add a partition to a table with aMAXVALUE
rule. However, you can use theALTER TABLE… SPLIT PARTITION
statement to split an existing partition. - You can't use the
ALTER TABLE… ADD SUBPARTITION
statement to add a subpartition to a table with aMAXVALUE
rule. However, you can split an existing subpartition with theALTER TABLE… SPLIT SUBPARTITION
statement.