Converting table from MyISAM to INNODB in MySQL?


For this, use ALTER command. Let us first create a table. The default engine is set as“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)

Following is the query to convert 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

Let us now check the status of table −

mysql> show create table DemoTable;

Output

This will produce the following output displaying 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)

Sharon Christine
Sharon Christine

An investment in knowledge pays the best interest

Updated on: 30-Jun-2020

135 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements