為此,請使用 ALTER 命令。讓我們首先創建一個表。默認引擎設置為“MYISAM” –
mysql> create table DemoTable -> ( -> ClientId int NOT NULL AUTO_INCREMENT, -> ClientName varchar(100), -> ClientAge int, -> ClientCountryName varchar(100), -> isMarried boolean, -> PRIMARY KEY(ClientId) -> )ENGINE=MyISAM; Query OK, 0 rows affected (0.67 sec)
登錄后復制
以下是將表從 MyISAM 轉換為 INNODB 的查詢 –
mysql> alter table DemoTable ENGINE=InnoDB; Query OK, 0 rows affected (1.97 sec) Records: 0 Duplicates: 0 Warnings: 0
登錄后復制
現在讓我們檢查表的狀態 –
mysql> show create table DemoTable;
登錄后復制
輸出
這將產生以下輸出,將更新后的引擎顯示為 InnoDB –
+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | DemoTable | CREATE TABLE `DemoTable` (`ClientId` int(11) NOT NULL AUTO_INCREMENT, `ClientName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `ClientAge` int(11) DEFAULT NULL, `ClientCountryName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `isMarried` tinyint(1) DEFAULT NULL, PRIMARY KEY (`ClientId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci | +--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
登錄后復制
以上就是在 MySQL 中將表從 MyISAM 轉換為 INNODB?的詳細內容,更多請關注www.92cms.cn其它相關文章!