如何在 MySQL 中将表格从 MyISAM 转换为 INNODB?
为此,请使用 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;
输出
这将产生以下输出,显示更新的 ENGINE 为 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)
广告