CREATE TABLE `goods` (
`id` varchar(36) NOT NULL,
`goods_name` varchar(256) NOT NULL COMMENT '产品名称',
`release_version` varchar(8) NOT NULL,
PRIMARY KEY (`release_version`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
;
alter table goods partition by list COLUMNS(release_version)(
PARTITION p20230926 VALUES in ('20230926')
);
-- 插入对应分区数据。现有对应分区,才能有对应分区的数据,否则插入失败
alter table goods add partition (
PARTITION p20231010 VALUES in ('20231010')
);
-- 插入对应分区数据。现有对应分区,才能有对应分区的数据,否则插入失败
-- 移除表分区,不会删除数据
ALTER TABLE goods REMOVE PARTITIONING ;