mysql分区(partition)

时间:2020-12-12 09:22:50

1)按范分区(range)

partition by range(Year(birthday))(

  partition p0 values less than 1960,

  partition p1 values less than 1970,

  partition p2 values less than 1980,

  partition p3 values less than 1990,

  partition p4 values less than 2000

);

  

2)按类型分区(list)

partition by list(store_id)(
partition p0 values in (1,2,3),
partition p1 values in (4,5,6),
partition p2 values in (7,8,9)
);

  

3)无规则分区(hash)

partition by hash(id)
partitions 5; 注意上面是"partitions",这个分区的意思是把所有记录平均分配到5个数据库分区里