Comparison between MyISAM and InnoDB In the MySQL database storage engine

Source: Internet
Author: User
Tags table definition

MySQL databaseOfStorage EngineIs what we will introduce in this article. It includes:MyISAMAndInnoDBMyISAM is the default storage engine of MySQL. Based on the traditional ISAM type, full-text search is supported, but it is not transaction-safe 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, and ACID transactions. It is not absolute to support row-level locking of InnoDB tables, 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, while InnoDB is transactional.

The granularity of MyISAM locks is 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 for cross-platform data transfer saves a lot of trouble.

InnoDB tables are safer than MyISAM tables. when data is not lost, you can switch non-transaction tables to the transaction table alter table tablename type = innodb ).

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. There are three types of table Storage ):

 
 
  1. show create table tablename  
  2. show table status from  dbname  where name=tablename 
  3. mysqlshow  -u user -p password --status dbname tablename  
  4.  

2. Modify the storage engine of the table:

 
 
  1. alter table tablename type=InnoDB 

3. Add the following parameters to the command line that starts the mysql database to make the newly published tables use transactions by default:

 
 
  1. default-table-type=InnoDB 

4. Temporarily change the default table Type:

 
 
  1. set table_type=InnoDB 
  2. show variables like 'table_type' 

This article introduces the storage engines MyISAM and InnoDB of MySQL databases. I hope this introduction will help you gain some benefits.

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.