如何在现有的mysql表中进行月份分区?

时间:2012-08-08 09:57:27

标签: mysql database partitioning

我有一张包含数十万条记录的表格。如何按月分区表?

1 个答案:

答案 0 :(得分:1)

您可以ALTER TABLE在其上创建新的PARITIONS

ALTER TABLE table_name PARTITION BY RANGE (MONTH(date_column)
(
  PARTITION JAN VALUES LESS THAN (2),
  PARTITION FEB VALUES LESS THAN (3),
  ...
  PARTITION DEC VALUES LESS THAN MAXVALUE
);