MySQL中預設啟用了INNODB嗎?


是的,從 MySQL 版本 4.0 開始,預設啟用了它。在此,我們使用 MySQL 版本 8.0.1 −

mysql> select version();
+-----------+
| version() |

+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.00 sec)

現在,讓我們檢查 my.ini,其中可以看到預設引擎型別 InnoDB −

我們首先建立兩個表。其中一個將使用引擎型別進行設定,而另一個將不會使用引擎型別進行設定。

第一個表 −

mysql> create table DemoTable1(Id int NOT NULL AUTO_INCREMENT PRIMARY KEY);
Query OK, 0 rows affected (0.80 sec)

第二個表使用 ENGINE InnoDB 設定 −

mysql> create table DemoTable2(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;
Query OK, 0 rows affected (0.76 sec)

無論你是否提到了引擎型別,上面兩個表都具有引擎型別 InnoDB。

讓我們檢查第一個表的引擎型別 −

mysql> select engine from information_schema.TABLES where TABLE_SCHEMA = 'web' and table_name='DemoTable1';
+--------+
| ENGINE |
+--------+
| InnoDB |
+--------+
1 row in set (0.56 sec)

現在,讓我們檢查第二個表的引擎型別 −

mysql> select engine from information_schema.TABLES where TABLE_SCHEMA = 'web' and table_name='DemoTable2';
+--------+
| ENGINE |
+--------+
| InnoDB |
+--------+
1 row in set (0.00 sec)

正如你可以看到的,上面兩個表都顯示引擎型別為“InnoDB”。即使我們沒有在 DemoTable1 中提到引擎型別,可見的引擎型別仍然是“InnoDB”。

更新於:2019 年 9 月 3 日

128 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

入門
廣告
© . All rights reserved.