Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1suOzD-006RsG-Bc for pgsql-general@arkaria.postgresql.org; Sat, 28 Sep 2024 04:23:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1suOzA-0028d6-6l for pgsql-general@arkaria.postgresql.org; Sat, 28 Sep 2024 04:23:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1suOz9-0028am-O1 for pgsql-general@lists.postgresql.org; Sat, 28 Sep 2024 04:23:11 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1suOz6-001QIT-Tr for pgsql-general@lists.postgresql.org; Sat, 28 Sep 2024 04:23:10 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a8d4979b843so365039866b.3 for ; Fri, 27 Sep 2024 21:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727497386; x=1728102186; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=oUOHQ0FUByBO+Bl5IjChLFtW9I5bC8FpsTgBZBnJqso=; b=LAl5gKBgeVmCHjj0Uq2o7svp1WLs/JX+G265rMOdpIosFGXbKlD3XVic5+kVhZH7EF Q/eOJ2ldQTb72RKimEKQvD2a8rSzbjb63VLcWEEeHreJyayIac8Ptvpk3H1Uiaisienq l2hM7WiegTLFpDPAHqfgZ3sbdLUznv4briRo9t5AYi4yVKD0DU4fOKgmeJi9LuQ7i1b0 zI9XCbu8wxMDuCW+z/0O+QaV91/8u2++bossiYq9b2Qz6Jtix/hnea45RYIFE4QxsgeL bqMWQZi+w2hlM6VsrpqVVgygWHuRBvQDs8wTAhsdYzkCxFLFG/BMuAHvC8qjVEBTZ87B EP9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727497386; x=1728102186; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=oUOHQ0FUByBO+Bl5IjChLFtW9I5bC8FpsTgBZBnJqso=; b=GiL+KmAdor2AI4W9cRotKj0RL4uF/8WmWhkVwWXLK5xl2iBj9JqTE6YFfs49CB4r0N WtihT5R1ZoRDpBZBMwTRQhXiDBu2zVJ5dX1Je1SlYVptcXf1LxYZGDndqhmuansd+4si hznxBZ/E71pye0mvNTkNgfsGKjqSdxMACG3LPhRW1MS00MuyLyCSFqBlAhe8Qk4rtAQG D8Gu6iQb4UivMrZddeBovQhJ3cSZPjajVJE/kXiVmLzYQFT+4zhbBlXYuvqF/V6GbIrv tSMcYYCcEymDMuL+YQRFyGekkILQwyCJaue6EuJ+SUDD+WisfGGNYoPWevqA+wX8pZu2 rrMQ== X-Gm-Message-State: AOJu0Yw4lQtgMS+8a900c+zJQu9TVrzYXkwtJO9xXLA6ahM7Fc5FYbBm eF2//F8oxxcgcKQpYI7ADYAK0Hh0z2L2x1QhF2ULEJvN/HuYiKHtgEDJsJ2YlSbUt/R54aqlDmB jJPmJpsJAWUqXxSuI5oG7bc74CkG55qgRl5s= X-Google-Smtp-Source: AGHT+IECchCjJ0+Yt2+wDW5da0vWsYRk4W9Ude+ybtlqId+fZdunM9EwTmsCdQPMu40zDOgM+GQf2BA7XpuWBpbV05c= X-Received: by 2002:a17:907:705:b0:a8d:7b7d:8c48 with SMTP id a640c23a62f3a-a93c49218e6mr547264166b.25.1727497385967; Fri, 27 Sep 2024 21:23:05 -0700 (PDT) MIME-Version: 1.0 From: Durgamahesh Manne Date: Sat, 28 Sep 2024 09:55:57 +0530 Message-ID: Subject: Regarding use of single column as primary key on partitioned table To: pgsql-general@lists.postgresql.org, pgsql-in-general@postgresql.org Content-Type: multipart/alternative; boundary="0000000000000a880e0623265489" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000a880e0623265489 Content-Type: text/plain; charset="UTF-8" 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 --0000000000000a880e0623265489 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Team
= test=3D> =C2=A0CREATE TABLE public.bet (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = betid int4 NOT NULL,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 externalbetid text NULL= ,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 externalsystem text NULL,
=C2=A0 =C2=A0= =C2=A0 =C2=A0 placedon timestamptz NULL,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cr= eatedon timestamptz NULL
) partition by list (placedon) ;
CREATE TABL= E
test=3D> alter table public.bet add primary key (betid);
ERROR: = =C2=A0unique constraint on partitioned table must include all partitioning = columns
DETAIL: =C2=A0PRIMARY KEY constraint on table "bet" la= cks column "placedon" which is part of the partition key.
test= =3D>

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

Regards,
Durga Mahesh
--0000000000000a880e0623265489--