若要在已分区表上创建unique或primary key约束,分区键必须不包含任何表达式或函数调用,并且约束的列必须包含所有分区键列。存在此限制是因为组成约束的各个索引只能在其自己的分区内直接强制唯一性;因此分区结构本身必须保证在不同分区中不存在重复
CREATE TABLE tracking_trackingdata
(
"id" uuid NOT NULL,
tracking_id varchar(100) NOT NULL,
dynamic_url_object_id bigint NOT NULL,
ip_address inet NOT NULL,
scan_time timestamp with time zone NOT NULL,
created timestamp with time zone NOT NULL,
modified timestamp with time zone NOT NULL,
CONSTRAINT PK_tracking_trackingdata PRIMARY KEY ( "id", scan_time ),
CONSTRAINT UK_tracking_id UNIQUE ( tracking_id, scan_time )
) PARTITION BY RANGE ( scan_time );
标签:tracking,scan,创建,约束,分区表,time,NULL,id
From: https://www.cnblogs.com/ywnxbx/p/17528450.html