主键必须包含表分区功能中的所有列

时间:2019-10-15 06:20:42

标签: mysql database

我有一个如下结构的表

CREATE TABLE `ACT_HI_VARINST` (

  `ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,

  `REV_` int(11) DEFAULT '1',

  `PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,

  `VAR_TYPE_` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `SCOPE_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `SUB_SCOPE_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `SCOPE_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `DOUBLE_` double DEFAULT NULL,

  `LONG_` bigint(20) DEFAULT NULL,

  `TEXT_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `TEXT2_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,

  `CREATE_TIME_` datetime(3) DEFAULT NULL,

  `LAST_UPDATED_TIME_` datetime(3) DEFAULT NULL,

  PRIMARY KEY (`ID_`),
  KEY `ACT_IDX_HI_PROCVAR_NAME_TYPE` (`NAME_`,`VAR_TYPE_`),

  KEY `ACT_IDX_HI_VAR_SCOPE_ID_TYPE` (`SCOPE_ID_`,`SCOPE_TYPE_`),

  KEY `ACT_IDX_HI_VAR_SUB_ID_TYPE` (`SUB_SCOPE_ID_`,`SCOPE_TYPE_`),

  KEY `ACT_IDX_HI_PROCVAR_PROC_INST` (`PROC_INST_ID_`),

  KEY `ACT_IDX_HI_PROCVAR_TASK_ID` (`TASK_ID_`),

  KEY `ACT_IDX_HI_PROCVAR_EXE` (`EXECUTION_ID_`),

  KEY `EXECUTION_ID_` (`EXECUTION_ID_`,`PROC_INST_ID_`,`TASK_ID_`,`NAME_`),

  KEY `IDX_CREATE_TIME` (`CREATE_TIME_`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

我想通过CREATE_TIME_

创建分区
ALTER TABLE ACT_HI_VARINST
PARTITION BY RANGE( TO_DAYS(CREATE_TIME_) ) (
PARTITION p2017 VALUES LESS THAN (TO_DAYS('2018-01-01')),
PARTITION p2018 VALUES LESS THAN (TO_DAYS('2019-01-01')),
PARTITION p2019 VALUES LESS THAN (TO_DAYS('2020-01-01')),
PARTITION p2020 VALUES LESS THAN (TO_DAYS('2021-01-01')),
PARTITION p2021 VALUES LESS THAN (TO_DAYS('2022-01-01')),
PARTITION p2022 VALUES LESS THAN (TO_DAYS('2023-01-01')),
PARTITION p2023 VALUES LESS THAN (TO_DAYS('2024-01-01')),
PARTITION p2024 VALUES LESS THAN (TO_DAYS('2025-01-01')),
PARTITION p2025 VALUES LESS THAN (TO_DAYS('2026-01-01')),
PARTITION p2026 VALUES LESS THAN (TO_DAYS('2027-01-01')),
PARTITION p2027 VALUES LESS THAN (TO_DAYS('2028-01-01')),
PARTITION p2028 VALUES LESS THAN (TO_DAYS('2029-01-01')),
PARTITION p2029 VALUES LESS THAN (TO_DAYS('2030-01-01')),
PARTITION p2030 VALUES LESS THAN (TO_DAYS('2031-01-01')),
PARTITION future VALUES LESS THAN MAXVALUE
);

但是我遇到了以下错误:

  

错误1503(HY000):主键必须包括   表的分区功能

0 个答案:

没有答案