Home > Database > Mysql Tutorial > body text

How to convert MyISAM storage engine in MySQL to InnoDB storage engine?

WBOY
Release: 2023-09-16 17:05:02
forward
1627 people have browsed it

How to convert MyISAM storage engine in MySQL to InnoDB storage engine?

To convert the MyISAM engine to InnoDB, we can use the ALTER command. Now let us 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)
Copy after login

Check whether the table was created using the MyISAM engine.

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

The following is the output of a table created using the MyISAM engine.

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

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

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

Check conversion.

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

This is the output.

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

The above is the detailed content of How to convert MyISAM storage engine in MySQL to InnoDB storage engine?. 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