我正在尝试使用PostgreSQL在Greenplum数据库中进行多列分区。然而,我不断得到一个错误-
错误:分区键有2列,但在VALUES中指定了1列第15行:VALUES(0001',2014-03-11'),^**********错误**********
错误:分区键有2列,但在VALUES中指定了1列子句SQL状态:42P16字符:341
这是我使用的查询:
CREATE TABLE EMP_TABLE
(
EMP_ID CHARACTER VARYING(9) NOT NULL,
JOB_ID CHARACTER VARYING(10) NOT NULL,
DT_OF_JOIN DATE NOT NULL,
SALARY NUMERIC(20,8) NOT NULL
-- CONSTRAINT ENTITY_MODEL_SCORE_PKEY PRIMARY KEY (ENTITY_ID, MODEL_ID, MODEL_RUN_DT)
)
WITH (
OIDS=FALSE
)
DISTRIBUTED BY (EMP_ID)
PARTITION BY LIST(EMP_ID,DT_OF_JOIN)
(
VALUES ('10001','2014-03-11'),
VALUES ('10002','2014-03-12')
)
我不确定我错过了什么。有人能帮助我使用PostgreSQL在Greenplum中进行多列分区的正确语法吗?
您可以在下面使用子分区进行尝试
CREATE TABLE sandbox.EMP_TABLE
(
EMP_ID CHARACTER VARYING(9) NOT NULL,
JOB_ID CHARACTER VARYING(10) NOT NULL,
DT_OF_JOIN date NOT NULL,
SALARY NUMERIC(20,8) NOT NULL
-- CONSTRAINT ENTITY_MODEL_SCORE_PKEY PRIMARY KEY (ENTITY_ID, MODEL_ID, MODEL_RUN_DT)
)
WITH (
OIDS=FALSE
)
DISTRIBUTED BY (JOB_ID)
PARTITION BY LIST(EMP_ID)
SUBPARTITION BY LIST(DT_OF_JOIN)
SUBPARTITION TEMPLATE
(
SUBPARTITION year1 VALUES ('2014-03-11'),
SUBPARTITION year2 VALUES ('2014-03-12')
)
(
values ('1001'),
values('10002')
)