mysql 以hash 分区
CREATE TABLE users (
uid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30) NOT NULL DEFAULT '',
email VARCHAR(30) NOT NULL DEFAULT ''
)
PARTITION BY HASH (uid) PARTITIONS 4 (
PARTITION p0
DATA DIRECTORY = 'D:/xampp/mysql/data2'
INDEX DIRECTORY = 'D:/xampp/mysql/data2',
PARTITION p1
DATA DIRECTORY = 'D:/xampp/mysql/data2'
INDEX DIRECTORY = 'D:/xampp/mysql/data2',
PARTITION p2
DATA DIRECTORY = 'D:/xampp/mysql/data2'
INDEX DIRECTORY = 'D:/xampp/mysql/data2',
PARTITION p3
DATA DIRECTORY = 'D:/xampp/mysql/data2'
INDEX DIRECTORY = 'D:/xampp/mysql/data2'
);
//最后面()内为指定数据及索引存放位置...
增加分区
ALTER TABLE `users` ADD PARTITION PARTITIONS 8;
增加后会自动重新分配数据到各表..
删除分区(同时会删除数据)
ALTER TABLE `users` drop PARTITION p2;