我有一个mysql表,按年分区,按月分区。
这里是创建语句。
CREATE TABLE `my_table` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` date NOT NULL,
`language` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL,
`title` text COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`,`created_at`),
KEY `created_at` (`created_at`),
) ENGINE=InnoDB AUTO_INCREMENT=1724800187 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8
/*!50100 PARTITION BY RANGE (YEAR(created_at))
SUBPARTITION BY HASH ( MONTH(created_at))
SUBPARTITIONS 12
(PARTITION p0 VALUES LESS THAN (2016) ENGINE = InnoDB,
PARTITION p1 VALUES LESS THAN (2017) ENGINE = InnoDB,
PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
我想重新组织分区,使p2只包含2018年的数据,而新分区(p3、p4和p5)将包含未来年份的数据。
在这种情况下,使用以下语句执行“重新组织分区”是否正确?
ALTER TABLE `my_table` REORGANIZE PARTITION `p2` INTO
(
PARTITION `p2` VALUES LESS THAN (2018) ENGINE = InnoDB,
PARTITION `p3` VALUES LESS THAN (2019) ENGINE = InnoDB,
PARTITION `p4` VALUES LESS THAN (2020) ENGINE = InnoDB,
PARTITION `p5` VALUES LESS THAN MAXVALUE
);
提前谢谢!