Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partition key failing error for postgres table

ERROR: no partition of relation "test_table" found for row DETAIL: Partition key of the failing row contains (start_time) = (2021-04-25 00:00:00). SQL state: 23514

I am inserting a data where i have a column start time (2021-04-25 00:00:00)

This is my Schema

CREATE TABLE test_table (
    start_time timestamp NULL,
)
PARTITION BY RANGE (start_time);
like image 388
DataDoctor Avatar asked Aug 06 '26 00:08

DataDoctor


1 Answers

This sounds as if you have no partition-tables defined for this table. You might need something like this:

CREATE TABLE test_table_2021 PARTITION OF test_table
    FOR VALUES FROM ('2021-01-01') TO ('2022-01-01');

After you defined this partition for your partitioned table, you should be able to insert the data (as long as start_time is anywhen in 2021).

See the docs: https://www.postgresql.org/docs/current/ddl-partitioning.html

like image 75
Islingre Avatar answered Aug 07 '26 16:08

Islingre