MySQL changes the table's storage engine

Source: Internet
Author: User
Tags table definition name database

MySQL provides a variety of database storage engines, and the storage engine is responsible for storing and extracting data from the MySQL database. Different storage engines have different characteristics, and sometimes it may be necessary to convert the storage engine of an existing table into another storage engine. There are many ways to complete such a conversion, each method will have advantages and disadvantages, should be based on the actual situation to choose. Here are three ways to convert the MySQL table engine:
ALTER TABLEThe simplest way to convert a MySQL table engine is to change the table definition directly using ALTER TABLE. The following statement converts the MyTable table engine to InnoDBmysql>alter TABLE mytable ENGINE = InnoDB;Advantages: Simple, can be used for whatever the table engine. Cons: It takes a long time to run, the process of converting is to define a new engine table and then copy the data from the original table.

The

consumes a large amount of system I/O capability during replication. Read locks are also added to the original table at the same time. So it doesn't work to use this kind of transformation in a very busy system, even though it's very easy. In addition, it should be noted that the conversion of the table engine in such a way would lose the attributes associated with the original table engine.

For example, convert a InnoDB table into a MyISAM table and then convert it to a InnoDB table. Even though you haven't done anything, the foreign keys in the original table will disappear.
import and export shell> mysqldump  -u   username  -P   Database name   Table name > file name VI change the CREATE TABLE statement in file mysql>  source with path file name

Span style= "font-size:14px" > Create and query

You do not need to export the entire table of data. Instead, create a new storage engine table first. Then use Insert .... The select syntax comes to the data. mysql>CREATE TABLE innodb_table like myisam_table; mysql>ALTER TABLE innodb_table ENGINE = InnoDB; mysql>INSERT into innodb_table SELECT * from myisam_table;

MySQL changes the table's storage engine

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.