Postgres natively partitioned tables - adding extra child columns
2
votes
1
answer
1484
views
With Postgres native partitioning, can you add extra columns to a partition of the base table? Like:
CREATE TABLE item (
tenant_id bigint NOT NULL,
item_id bigint NOT NULL,
kind text NOT NULL CHECK ( kind IN ('product', 'ingredient') ),
PRIMARY KEY (tenant_id, item_id)
) PARTITION BY LIST (kind);
CREATE TABLE item_product PARTITION OF item (
extra_sku TEXT
) FOR VALUES IN ('product');
CREATE TABLE item_ingredient PARTITION OF item
FOR VALUES IN ('ingredient');
The [CREATE TABLE
] syntax doesn't seem to support adding columns on child tables, only adding constraints to existing columns, so I'm guessing it's not allowed.
Asked by Joe
(179 rep)
Jul 7, 2021, 01:59 AM
Last activity: Apr 10, 2023, 01:01 PM
Last activity: Apr 10, 2023, 01:01 PM