MySQL中的MyISAM与InnoDB?
两者都是发动机类型。这是查询,通过它我们可以了解正在使用的引擎类型和表。首先,我们将在USE命令的帮助下选择数据库-
mysql> USE business; Database changed
这是查询,通过它我们可以知道正在使用哪个表或引擎-
mysql> SHOW table status;
以下是输出
+------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ |Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length |Max_data_length | Index_length | Data_free | Auto_increment | Create_time |Update_time | Check_time | Collation | Checksum | Create_options |Comment | +------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ | addcolumntable | InnoDB | 10 | Dynamic | 0 | 0 | 16384 | 0 | 0 | 0 | NULL |2018-09-27 13:14:31 | NULL |NULL |utf8mb4_0900_ai_ci |NULL | | | | autoincrement | InnoDB | 10 | Dynamic | 4 | 4096 | 16384 | 0 | 0 | 0 | 4 |2018-10-06 13:28:25 | NULL |NULL |utf8mb4_unicode_ci | NULL | | | | autoincrementtable | InnoDB | 10 | Dynamic | 5 | 3276 | 16384 | 0 | 0 | 0 | 1001 |2018-10-04 09:39:47 | NULL | NULL |utf8mb4_unicode_ci | NULL | | | | bookindexes | InnoDB | 10 | Dynamic | 4 | 4096 | 16384 | 0 |16384 | 0 | NULL | 2018-10-01 16:28:10 | NULL | NULL |utf8mb4_unicode_ci | NULL | | | | chardemo | InnoDB | 10 | Dynamic | 0 | 0 | 16384 | 0 |0 | 0 | NULL | 2018-09-28 11:00:28 | NULL | NULL | utf8mb4_0900_ai_ci |NULL | | | | clonestudent | InnoDB | 10 | Dynamic | 3 | 5461 | 16384 | 0 |32768 | 0 | NULL | 2018-10-10 09:36:03 | NULL | NULL |utf8mb4_unicode_ci | NULL | | | | columnvaluenulldemo | InnoDB | 10 | Dynamic | 2 | 8192 | 16384 | 0 |0 | 0 | NULL | 2018-10-05 12:06:27 | NULL | NULL |utf8mb4_unicode_ci | NULL | | | | dateadddemo | InnoDB | 10 | Dynamic | 0 | 0 | 16384 | 0 |0 | 0 | NULL | 2018-10-08 09:47:46 | NULL | NULL | utf8mb4_unicode_ci | NULL | | | | deletedemo | InnoDB | 10 | Dynamic | 5 | 3276 | 16384 | 0 |0 | 0 | NULL | 2018-10-09 17:18:38 | NULL | NULL | utf8mb4_unicode_ci | NULL | | | | deleterecord | InnoDB | 10 | Dynamic | 6 | 2730 | 16384 | 0 |
因此,在MySQL版本8.0.12中,表使用引擎“innodb”,但是我们可以将引擎类型更改为MyISAM。
这是要更改的查询-
mysql> SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA, '.', TABLE_NAME,' ENGINE=MyISAM;') -> from Information_schema.TABLES WHERE TABLE_SCHEMA = 'sample' AND ENGINE -> = 'InnoDB' AND TABLE_TYPE = 'mytable'; Empty set (0.05 sec)