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

Convert table from MyISAM to INNODB in MySQL?

王林
Release: 2023-09-08 08:21:11
forward
515 people have browsed it

在 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)
Copy after login

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
Copy after login

Now let us check the status of the table-

mysql> show create table DemoTable;
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template