MySQL - 將表格引擎從 innoDB 更改為 MyISAM?


讓我們先建立一個表 -

mysql> create table DemoTable1982
   (
   StudentId int
   ,
   StudentName varchar(20),
   StudentAge int
   );
Query OK, 0 rows affected (0.00 sec)

讓我們檢查一下表引擎型別 -

mysql> show create table DemoTable1982;

這會產生以下輸出 -

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table         | Create Table                                                                                                                                                                                                                         |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DemoTable1982 | CREATE TABLE `demotable1982` (`StudentId` int(11) DEFAULT NULL, `StudentName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `StudentAge` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

以下是可以將表引擎從 innoDB 更改為 MyISAM 的查詢 -

mysql> alter table DemoTable1982 ENGINE='MyISAM';
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

現在讓我們檢查一下表引擎的型別 -

mysql> show create table DemoTable1982;

這會產生以下輸出 -

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table         | Create Table                                                                                                                                                                                                                           |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DemoTable1982 | CREATE TABLE `demotable1982` ( `StudentId` int(11) DEFAULT NULL, `StudentName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `StudentAge` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

更新於:2019 年 12 月 31 日

284 次瀏覽

開始你的職業生涯

在完成課程後,獲得認證。

開始吧
廣告