How to convert MyISAM to InnoDB storage engine in MySQL?


To convert the MyISAM Engine to InnoDB, we can use the ALTER command. Let us now create a table with the help of engine MyISAM.

mysql> create table MyISAMToInnoDBDemo
   -> (
   -> id int,
   -> Name varchar(100)
   -> )ENGINE=MyISAM;
Query OK, 0 rows affected (0.19 sec)

To check if the table is created with engine MyISAM or not.

mysql> SELECT TABLE_NAME,ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'business' and ENGINE = 'MyISAM';

The following is the output that displays the table created with MyISAM engine.

+-------------------------+--------+
| TABLE_NAME              | ENGINE |
+-------------------------+--------+
| studentrecordwithmyisam | MyISAM |
+-------------------------+--------+
1 row in set (0.00 sec)

We can convert MyISAM to InnoDB with the help of ALTER command.

mysql> alter table MyISAMToInnoDBDemo engine=InnoDB;
Query OK, 0 rows affected (1.65 sec)
Records: 0  Duplicates: 0  Warnings: 0

To check the conversion.

mysql> SELECT TABLE_NAME,ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'test' and ENGINE = 'InnoDB';

Here is the output.

+--------------------+--------+
| TABLE_NAME         | ENGINE |
+--------------------+--------+
| myisamtoinnodbdemo | InnoDB |
+--------------------+--------+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

195 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements