The default partition
In this section, we will see what happens if we insert data into a partitioned table where the child partition does not exist, and how to resolve the inconvenience this causes. To simulate this problem, suppose we want to insert a date corresponding to 2023-05-01
on the table called part_tags
. We would get this result:
forumdb=> insert into part_tags (tag,ins_date,level) values ('Ubuntu Linux','2023-05-01',2);
ERROR: no partition of relation "part_tags" found for row
DETAIL: Partition key of the failing row contains (ins_date) = (2023-05-01).
This happens because PostgreSQL does not have a correspondence between the date of 2023-05-01
and those present on the mapping of the child tables.
To eliminate this drawback, it is necessary to use a default partition where all the values that are not reflected in the mapping of the child tables will be inserted.
To do this let’s execute the following statement...