MYSQL的分区字段,必须包含在主键字段内。就是要分区的字段必须为主键索引。
如下所示,season必须为主键索引。
-- list分区示例
CREATE TABLE IF NOT EXISTS `product` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `season` tinyint (1) not null default '2' comment '季节', primary key(id,season) )engine=MyISAM default charset=utf8 partition by list (season)( partition g1 values in (1), partition g2 values in (2), partition g3 values in (3), partition g4 values in (4) );
http://www.2cto.com/database/201503/380348.html
http://www.jb51.net/article/62290.htm