In-depth discussion: Comparison between MySQL database MyISAM and InnoDB Storage Engine

Source: Internet
Author: User
Tags types of tables

MySQL has multiple storage engines. MyISAM and InnoDB are two common storage engines. Here we will introduce some basic concepts about the two engines (not in depth ).
MyISAM is the default storage engine of MySQL. Based on the traditional ISAM type, full-text search is supported, but it is not transaction secure and does not support foreign keys. Each MyISAM table is stored in three files: the frm file stores the table definition, the data file is MYD (MYData), and the index file is MYI (MYIndex ).
InnoDB is a transaction engine that supports rollback, crash recovery, multi-version concurrency control, ACID transactions, and row-level locking. (row locks of InnoDB tables are not absolute, if MySQL cannot determine the scope of the scan when executing an SQL statement, the InnoDB table will also lock the entire table, such as the SQL statement during the like operation ), and provides the same non-lock read method as Oracle. InnoDB stores its tables and indexes in one tablespace, which can contain several files.
Main differences:
• MyISAM is non-transactional secure, while InnoDB is transactional secure.
• MyISAM locks are table-level, while InnoDB supports row-level locks.
• MyISAM supports full-text indexes, while InnoDB does not.
• MyISAM is relatively simple, so it is more efficient than InnoDB. For small applications, you can consider using MyISAM.
• MyISAM tables are saved as files. Using MyISAM storage in cross-platform data transfer saves a lot of trouble.
• The InnoDB table is safer than the MyISAM table, so that the non-transaction table can be switched to the transaction table (alter table tablename type = innodb) without data loss ).
Application scenarios:
• MyISAM manages non-transaction tables. It provides high-speed storage and retrieval, as well as full-text search capabilities. If the application needs to execute a large number of SELECT queries, MyISAM is a better choice.
• InnoDB is used for transaction processing applications and has many features, including ACID transaction support. If the application requires a large number of INSERT or UPDATE operations, InnoDB should be used to improve the performance of multi-user concurrent operations.
Common commands:
(1) view the Storage types of tables (three types ):
• Show create table tablename
• Show table status from dbname where name = tablename
• Mysqlshow-u user-p password -- status dbname tablename
(2) modify the storage engine of the table:
• Alter table tablename type = InnoDB
(3) Add the following parameters to the command line that starts the mysql database to enable transactions for newly published tables by default:
• -- Default-table-type = InnoDB
(4) temporarily change the default table Type:
• Set table_type = InnoDB
• Show variables like 'table _ type'

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.