MySQL多列分區 一個針對MySQL5.5 COLUMNS分區的實例 創建表: Java代碼 drop table if exists partition_test;CREATE TABLE `partition_test` ( `t_id` int(11) NOT NULL AUTO_INCREMENT, `test_date` datetime NOT NULL, `t_key` varchar(16), `test_info` varchar(50) DEFAULT 'test', PRIMARY KEY (`t_id`,`test_date`,`t_key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY RANGE COLUMNS (test_date,t_key) ( PARTITION p201303151 VALUES LESS THAN ('2013-03-15','m2'), PARTITION p201303152 VALUES LESS THAN ('2013-03-15','m3'), PARTITION p201303161 VALUES LESS THAN ('2013-03-16','m2'), PARTITION p201303162 VALUES LESS THAN ('2013-03-16','m3'), PARTITION p201303171 VALUES LESS THAN ('2013-03-17','m2'), PARTITION p201303172 VALUES LESS THAN ('2013-03-17','m3') ); 注意兩點:1、5.5新增COLUMNS分區後,時間不再需要時間轉換函數;2、分區字段必須為主鍵 增加表分區 Java代碼 alter table `partition_test` add PARTITION(PARTITION p201303181 VALUES LESS THAN ('2013-03-18','m2')); 刪除表分區(刪除分區會刪除分區中的數據) Java代碼 alter table `partition_test` DROP PARTITION p201303181;