您可以在多个驱动器上对表进行分区.请查看官方手册,其中深入介绍了该主题.
以下是在多个驱动器上对现有表进行分区的示例:
ALTER TABLE mytable
PARTITION BY RANGE (mycolumn)(
PARTITION p01 VALUES Less Than (10000)
DATA DIRECTORY = "/mnt/disk1"
INDEX DIRECTORY = "/mnt/disk1",
PARTITION p02 VALUES Less Than (20000)
DATA DIRECTORY = "/mnt/disk2"
INDEX DIRECTORY = "/mnt/disk2",
PARTITION p03 VALUES Less Than MAXVALUE
DATA DIRECTORY = "/mnt/disk3"
INDEX DIRECTORY = "/mnt/disk3"
);
请注意,这需要关闭NO_DIR_IN_CREATE.它似乎不适用于Windows,它似乎不适用于InnoDB.
如果最后一个分区上的磁盘空间不足,可以使用以下语句将其拆分:
ALTER TABLE mytable REORGANIZE PARTITION p03 INTO
(
PARTITION p03 VALUES Less Than (30000)
DATA DIRECTORY = "/mnt/disk3"
INDEX DIRECTORY = "/mnt/disk3",
PARTITION p04 VALUES Less Than MAXVALUE
DATA DIRECTORY = "/mnt/disk4"
INDEX DIRECTORY = "/mnt/disk4"
);