ERROR: insufficient columns in the PRIMARY KEY constraint definition
Nagaraj Raj <nagaraj.sf@yahoo.com>
From: Nagaraj Raj <nagaraj.sf@yahoo.com>
To: Pg Bugs <pgsql-bugs@postgresql.org>
Date: 2020-09-29T21:36:02Z
Lists: pgsql-bugs
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.
Commits
-
Reword partitioning error message
- f669ba7bdb00 12.5 landed
- 9fc212271289 14.0 landed
- 5b76e8fb675e 11.10 landed
- 49433744ff65 13.1 landed
-
Doc: Improve clarity on partitioned table limitations
- ab0c9c073563 11.10 landed
- 5c7afb4a29aa 12.5 landed
- 5610ffaf00a5 13.1 landed
- 2b888647d864 14.0 landed