时间:2021-07-01 10:21:17 帮助过:8人阅读
和Oracle不一样的是:MySQL没有全局索引,只有分区索引,因此对于MySQL的分区表来说,限制比Oracle要多一些:
1、分区键必须是主键的一部分
2、分区键的数据类型必须是整形(包括时间类型)
3、分区键不能为NULL
下面是一个基于时间的表分区定义:
PARTITION BY RANGE (TO_DAYS(START))( PARTITION p201401 VALUES LESS THAN (TO_DAYS('20140201')), PARTITION p201402 VALUES LESS THAN (TO_DAYS('20140301')), PARTITION p201403 VALUES LESS THAN (TO_DAYS('20140401')), PARTITION p201404 VALUES LESS THAN (TO_DAYS('20140501')), PARTITION p201405 VALUES LESS THAN (TO_DAYS('20140601')), PARTITION p201406 VALUES LESS THAN (TO_DAYS('20140701')), PARTITION p201407 VALUES LESS THAN (TO_DAYS('20140801')), PARTITION p201408 VALUES LESS THAN (TO_DAYS('20140901')), PARTITION p201409 VALUES LESS THAN (TO_DAYS('20141001')), PARTITION p201410 VALUES LESS THAN (TO_DAYS('20141101')), PARTITION p201411 VALUES LESS THAN (TO_DAYS('20141201')), PARTITION p201412 VALUES LESS THAN (TO_DAYS('20150101')), PARTITION pmax VALUES LESS THAN maxvalue);