partition分区
1、按id拆分
mysql -uroot mysql>use test; mysql>create table topic ( tid int primary key auto_increment,title char(20) not null default '')engine myisam charset utf8 partition by range(tid)(partition t0 values less than (10),partition t1 values less than (20),partition t2 values less than(MAXVALUE)); #插入t1 mysql>insert into topic(title) values('aa'); #插入t2 mysql>insert into topic(id,title) values(11,'aa');
2、按表数据拆分
mysql -uroot mysql>use test; mysql>create table area(aid int,zone)engine mysiam charset utf8; mysql>insert into area values(1,'bj'),(2,'hb'),(3,'sx'),(4,'ah'); mysql>create table user(uid int,uname char(6),aid int)engine myisam charset utf8 partition by list(aid)(partition bj values in (1),partition hb values in (2),partition xs values in (3),partition ah values in (4)); #插入bj块 mysql>insert into user(uname,aid) values('poly',1); #插入hb块 mysql>insert into user(uname,aid) values('lily',2);