createtableDemoTable->(->ClientIdintNOTNULLAUTO_INCREMENT,->ClientNamevarchar(100),->ClientAgeint,->ClientCountryNamevarchar(100),->isMarriedboolean,->PRIMARYKEY(ClientId)->)EN"/> createtableDemoTable->(->ClientIdintNOTNULLAUTO_INCREMENT,->ClientNamevarchar(100),->ClientAgeint,->ClientCountryNamevarchar(100),->isMarriedboolean,->PRIMARYKEY(ClientId)->)EN">

Home  >  Article  >  Database  >  Convert table from MyISAM to INNODB in MySQL?

Convert table from MyISAM to INNODB in MySQL?

王林
王林forward
2023-09-08 08:21:11499browse

在 MySQL 中将表从 MyISAM 转换为 INNODB?

To do this, use the ALTER command. Let's first create a table. The default engine is set to "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)

The following is the query to convert the table from MyISAM to INNODB-

mysql> alter table DemoTable ENGINE=InnoDB;
Query OK, 0 rows affected (1.97 sec)
Records: 0 Duplicates: 0 Warnings: 0

Now let us check the status of the table-

mysql> show create table DemoTable;

Output

This will produce the following output showing the updated engine as 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)

The above is the detailed content of Convert table from MyISAM to INNODB in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete