为此,请使用 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?的详细内容。更多信息请关注PHP中文网其他相关文章!