Mysql表分区实操
创建分区表
create table user(id int(11) not null,name varchar(32) not null)
partition by range(id)
(
partition p0 values less than(10),
partition p1 values less than(20),
partition p2 values less than(30),
partition p3 values less than maxvalue
)
分区表数据存储
数据存储文件将根据分区被拆分成多份
分区数据查询
构造数据
insert into user values(1,'Kobe Bryant');
insert into user values(12,'Allen Iverson');
insert into user values(22,'Tracy McGrady');
insert into user values(50,'Vince Carter');
普通表与分区表的互转
ALTER TABLE students PARTITION BY KEY(sid) PARTITIONS 2;
移除分区信息
ALTER TABLE user remove partitioning;