Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

automatic table partition when data insert

I have table which is contained list partition in postgres database

create table test(id int, name character varying) partition by list(id);

when I insert data, it is throwing an error.

insert into test values(1,'test1'),(2,'test2')
ERROR: Partition key of the failing row contains (id) = (1).no partition of relation "test" found for row

Note: as now I cannot predefine what are the id's can insert

Based on the id's inserted on table, postgres tables needs to partitioned automatically

Answer*

Draft saved
Draft discarded
Cancel
2
  • is the same requirement achievable using pg_cron jobs? if yes how it is Commented Oct 10, 2024 at 13:35
  • It depends how you partition your data. If you partitioned it by some date field (say one partition per day), I would imagine you could have a cron that creates a new partition table for the next day. But this is a whole new queston – feel free to submit a new one. Commented Oct 10, 2024 at 15:57

lang-sql

AltStyle によって変換されたページ (->オリジナル) /