Regarding use of single column as primary key on partitioned table

From: Durgamahesh Manne <maheshpostgres9(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org, pgsql-in-general(at)postgresql(dot)org
Subject: Regarding use of single column as primary key on partitioned table
Date: 2024-09-28 04:25:57
Message-ID: CAJCZko+pA8o3HDBuGzxzYjMo=Gm_8yBLk7Sod3Fdo-i0WAwLuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-in-general

Hi Team
test=> CREATE TABLE public.bet (
betid int4 NOT NULL,
externalbetid text NULL,
externalsystem text NULL,
placedon timestamptz NULL,
createdon timestamptz NULL
) partition by list (placedon) ;
CREATE TABLE
test=> alter table public.bet add primary key (betid);
ERROR: unique constraint on partitioned table must include all
partitioning columns
DETAIL: PRIMARY KEY constraint on table "bet" lacks column "placedon"
which is part of the partition key.
test=>

Can't we use primary key on singal column(betid) on partitioned table
rather than using composite key (placedon,betid)?

Regards,
Durga Mahesh

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2024-09-28 04:39:21 Re: Regarding use of single column as primary key on partitioned table
Previous Message Tom Lane 2024-09-27 22:37:35 Re: Request for Insights on ID Column Migration Approach

Browse pgsql-in-general by date

  From Date Subject
Next Message David G. Johnston 2024-09-28 04:39:21 Re: Regarding use of single column as primary key on partitioned table
Previous Message Durgamahesh Manne 2024-09-25 20:53:39 Re: Synchronize the dump with a logical slot with --snapshot