I am using Postgress 14 and using the pg_partman
for table partition using native.
In the script below, the vpart_daily script contains pk_vpart_daily within its content. In script vpart_daily_template
, Primary key is not in table, but created on the template.
I'd like to understand the significance of having the primary key created on both the table and the template in pg_partman.
CREATE TABLE vpart_daily
(
id INT,
created_timstm timestamp Default current_timestamp,
created_user_id VARCHAR(50) ,
CONSTRAINT pk_vpart_daily PRIMARY KEY (id,created_timstm)
) PARTITION BY RANGE (created_timstm);
CREATE TABLE vpart_daily_template
(
id INT,
created_timstm timestamp Default current_timestamp,
created_user_id VARCHAR(50) ,
) PARTITION BY RANGE (created_timstm);
Create table partman.vpart_daily_template1 ( LIKE vpart_daily_template);
Alter table partman.vpart_daily_template1 ADD Primary key (id,created_timstm);