合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
#### key(键值) 面Hash模式的一种延伸,这里的Hash Key是MySQL系统产生的。 可以简单理解为,通过“求余”算法把记录分配到不同的分区。 #### 语法 ~~~ create table p_key( id int, name varchar(32), birthday date )engine myisam charset utf8 partition by key (id) partitions 5; ~~~ #### 文件夹结构 ![](https://box.kancloud.cn/0ad04b68d897a656ef921d52447fed00_850x259.png) #### 测试 ~~~ explain partitions select * from p_key where id = 2000\G ~~~ 结果: ~~~ id: 1 select_type: SIMPLE table: p_key partitions: p1 //使用了自动分区 type: const possible_keys: PRIMARY key: PRIMARY key_len: 4 ref: const rows: 1 filtered: 100.00 Extra: NULL ~~~