pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nagaraj Raj <nagaraj.sf@yahoo.com>
To: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: ERROR:  insufficient columns in the PRIMARY KEY constraint definition
Date: Tue, 29 Sep 2020 21:41:48 +0000 (UTC)
Message-ID: <221078363.71188.1601415708799@mail.yahoo.com> (raw)
In-Reply-To: <64062533.78364.1601415362244@mail.yahoo.com>
References: <64062533.78364.1601415362244.ref@mail.yahoo.com>
	<64062533.78364.1601415362244@mail.yahoo.com>

 Added three scenarios, Postgres 11 | db<>fiddle

| 
| 
|  | 
Postgres 11 | db<>fiddle

Free online SQL environment for experimenting and sharing.
 |

 |

 |




    On Tuesday, September 29, 2020, 02:36:17 PM PDT, Nagaraj Raj <nagaraj.sf@yahoo.com> wrote:  
 
 

I recently upgraded the database from PostgreSQL v9.6 to v11.7. we have some partitioned table with `inherence` and planning to migrate them to the `declaration`.
Table DDL:

CREATE TABLE c_account_p(    billing_account_guid character varying(40)  NOT NULL,    ingestion_process_id bigint NOT NULL DEFAULT '-1'::integer,    load_dttm timestamp(6) without time zone NOT NULL,    ban integer NOT NULL,    CONSTRAINT billing_account_pkey PRIMARY KEY (billing_account_guid, ban)) PARTITION by RANGE(load_dttm);


When I try the create table, it's throwing below error:
ERROR:  insufficient columns in the PRIMARY KEY constraint definitionDETAIL:  PRIMARY KEY constraint on table "l_billing_account_p" lacks column "load_dttm" which is part of the partition key.SQL state: 0A000

Is it mandatory/necessary that the `partition column` should be a primary key? cause if I  include `load_dttm` as `PK` then its working fine.
If the partition column should be supposed to be a PK, it's challenging to create a partition by range with the date column, cause the load_dttm column chances to have duplicate if data loaded `COPY`.

Could some please help me to understand this scenario?   https://dbfiddle.uk/?rdbms=postgres_11&fiddle=5000c4602c16350d77974868e62dc7c9  

Thanks.





  

view thread (19+ messages)  latest in thread

Message-ID: <221078363.71188.1601415708799@mail.yahoo.com>
Permalink:  ../221078363.71188.1601415708799@mail.yahoo.com/
Also on:    postgresql.org/message-id/221078363.71188.1601415708799@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: nagaraj.sf@yahoo.com
  Subject: Re: ERROR:  insufficient columns in the PRIMARY KEY constraint definition
  In-Reply-To: <221078363.71188.1601415708799@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox