add分区的那些事

CREATE TABLE `test` (

`id` int(10) unsigned NOT NULL AUTO_INCREMENT,

`group_article_type` tinyint(3) unsigned NOT NULL COMMENT ‘1帖子2新闻’,

`group_article_id` int(10) unsigned NOT NULL COMMENT ‘ 帖子、新闻id’,

`pid` int(10) unsigned NOT NULL DEFAULT ‘0’ COMMENT ‘论坛,新声对应的 评论id’,

`uid` int(10) unsigned NOT NULL COMMENT ‘用户id’,

`username` varchar(30) NOT NULL COMMENT ‘用户昵称’,

`content` mediumtext, `dynstr` mediumblob NOT NULL COMMENT ‘虚拟动态列’,

`lights` smallint(5) unsigned NOT NULL DEFAULT ‘0’ COMMENT ‘亮’,

`create_at` int(10) unsigned NOT NULL COMMENT ‘回复时间(时间戳)’,

PRIMARY KEY (`id`,`group_article_id`),

KEY `group_article_type` (`group_article_type`,`group_article_id`),

KEY `pid` (`pid`) )

ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT=’回复表(帖子、新闻)’

group_article_id:必须是主键

PARTITION BY RANGE (group_article_id) (

PARTITION p1 VALUES LESS THAN (3)ENGINE = InnoDB,

PARTITION p2 VALUES LESS THAN (6) ENGINE = InnoDB,

PARTITION p3 VALUES LESS THAN (9) ENGINE = InnoDB,

PARTITION p4 VALUES LESS THAN (12) ENGINE = InnoDB

)

alter table group_reply5 add PARTITION (PARTITION p4 VALUES LESS THAN (12));


发表评论

电子邮件地址不会被公开。 必填项已用*标注