1、建立语句
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '名称',
`sex` int(1) NOT NULL DEFAULT '0' COMMENT '0为男,1为女',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (3),
PARTITION p1 VALUES LESS THAN (6),
PARTITION p2 VALUES LESS THAN (9),
PARTITION p3 VALUES LESS THAN (12),
PARTITION p4 VALUES LESS THAN MAXVALUE
);
插入数据
INSERT INTO user(`name` ,`sex`)VALUES ('tank', '0')
,('zhang',1),('ying',1),('张',1),('映',0),('test1',1),('tank2',1)
,('tank1',1),('test2',1),('test3',1),('test4',1),('test5',1),('tank3',1)
,('tank4',1),('tank5',1),('tank6',1),('tank7',1),('tank8',1),('tank9',1)
,('tank10',1),('tank11',1),('tank12',1),('tank13',1),('tank21',1),('tank42',1)
删除一个分区
alter table user drop partition p4;