從MySQL 8.0版本開始,就不容許建立 MyISAM 分區表了,只容許建立已經實現了本地分區策略的引擎。數據庫
到目前爲止,只有InnoDB和NDB這兩個引擎支持本地分區策略。測試
【1】實際測試this
(1)數據庫版本號spa
# 獲取版本號 SELECT VERSION(); # 8.0.12
(2)建表(InnoDB引擎)3d
CREATE TABLE `t_innodb` ( `ftime` DATETIME NOT NULL, `c` INT(11) DEFAULT NULL, KEY (`ftime`) ) ENGINE=INNODB DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(ftime)) (PARTITION p_2017 VALUES LESS THAN (2017) ENGINE = INNODB, PARTITION p_2018 VALUES LESS THAN (2018) ENGINE = INNODB, PARTITION p_2019 VALUES LESS THAN (2019) ENGINE = INNODB, PARTITION p_others VALUES LESS THAN MAXVALUE ENGINE = INNODB);
建立成功。code
(3)建表(MyiSAM引擎)blog
CREATE TABLE `t_myisam` ( `ftime` DATETIME NOT NULL, `c` INT(11) DEFAULT NULL, KEY (`ftime`) ) ENGINE=INNODB DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(ftime)) (PARTITION p_2017 VALUES LESS THAN (2017) ENGINE = MYISAM, PARTITION p_2018 VALUES LESS THAN (2018) ENGINE = MYISAM, PARTITION p_2019 VALUES LESS THAN (2019) ENGINE = MYISAM, PARTITION p_others VALUES LESS THAN MAXVALUE ENGINE = MYISAM);
建立失敗:hash
錯誤代碼:1497
The mix of handlers in the partitions is not allowed in this version of MySQLit
(4)建表(不支持本地分區策略)io
CREATE TABLE `t_partition_by_hash` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `sName` VARCHAR(10) NOT NULL, `sAge` INT(2) UNSIGNED ZEROFILL NOT NULL, `sAddr` VARCHAR(20) DEFAULT NULL, `sGrade` INT(2) NOT NULL, `sStuId` INT(8) DEFAULT NULL, `sSex` INT(1) UNSIGNED DEFAULT NULL ) ENGINE=MYISAM PARTITION BY HASH(id) PARTITIONS 4;
建立失敗:
錯誤代碼:1178
The storage engine for the table doesn't support native partitioning
Good Good Study, Day Day Up.
順序 選擇 循環 總結