Differences between engine = innodb and engine = myisam in mysql

Source: Internet
Author: User
The MyISAM type does not support advanced processing such as transaction processing, while the InnoDB type supports. This article will explain the differences between engineinnodb and enginemyisam in mysql. If you do not know how to learn, I hope it will be helpful for you. When you first use MySQLAdministrator to create a database, the default table type is InnoDB, so you don't care. Later, Ac

The MyISAM type does not support advanced processing such as transaction processing, while the InnoDB type supports. This article will explain the differences between engine = innodb and engine = myisam in mysql. If you do not know how to learn, I hope it will be helpful for you. When you first use MySQL Administrator to create a database, the default table type is InnoDB, so you don't care. Later, Ac

The MyISAM type does not support advanced processing such as transaction processing, while the InnoDB type supports. This article will explain the differences between engine = innodb and engine = myisam in mysql. If you do not know how to learn, hope to help you

When I first used MySQL Administrator to create a database, the table is of the InnoDB type by default, so I did not care about it. Later, when using Access2MySQL to export data, I found that only tables of the MyISAM type can be imported. I checked the differences between the two types. Originally, the MyISAM type does not support advanced processing such as transaction processing, while the InnoDB type does. MyISAM tables emphasize performance, and the execution speed is faster than that of InnoDB, but transactions are not supported. InnoDB provides advanced database functions such as external keys for transactions. In this way, Different Storage types can be used for different data tables.

In addition, binary data files of the MyISAM type can be migrated in different operating systems. That is, it can be copied directly from Windows to linux.

Modify:

Alter table tablename ENGINE = MyISAM;

MyISAM: This is the default type. It is based on the traditional ISAM type, and ISAM is the abbreviation of Indexed Sequential Access Method (Sequential Access Method with indexes, it is a standard method for storing records and files. compared with other storage engines, MyISAM has most tools for checking and repairing tables. myISAM tables can be compressed and support full-text search. they are not transaction-safe and do not support foreign keys. If a transaction is rolled back, incomplete rollback is not atomic. If you execute a large number of SELECT statements, MyISAM is a better choice.

InnoDB: This type is transaction-safe. it has the same features as the BDB type and supports foreign keys. the InnoDB table is fast. it has more features than BDB. Therefore, if you need a transaction-safe storage engine, we recommend that you use it. if your data executes a large number of INSERT or UPDATE operations, InnoDB tables should be used for performance considerations,

For the InnoDB type labels that support transactions, AUTOCOMMIT is enabled by default, and the program does not explicitly call BEGIN to start transactions, as a result, each inserted entry is automatically Commit, seriously affecting the speed. You can call begin before executing the SQL statement. Multiple SQL statements form a transaction (even if you open the autocommit statement), which greatly improves the performance.

========================================================== ======================================
1. MySQL 4.0 and above support transactions, including non-max versions. 3.23 requires the max version mysqld to support transactions.

2. If no type is specified during table creation, the default value is myisam. transactions are not supported.
You can run the show create table tablename command to view the table type.

2.1 The start/commit operation on a table that does not support transactions has no effect. It has been submitted before the execution of the commit operation. test:
Execute an msyql:
Use test;
Drop table if exists tn;
Create table tn (a varchar (10) type = myisam;
Drop table if exists ty;
Create table ty (a varchar (10) type = innodb;

Begin;
Insert into tn values ('A ');
Insert into ty values ('A ');
Select * from tn;
Select * from ty;
You can see a record.

Execute another mysql:
Use test;
Select * from tn;
Select * from ty;
Only tn can see one record
Then on the other side
Commit;
You can see the record.

3. You can run the following command to switch the non-transaction table to the transaction (data will not be lost). The innodb table is safer than the myisam table:
Alter table tablename type = innodb;

3.1 innodb tables cannot use the repair table command and myisamchk-r table_name
However, you can use check table and mysqlcheck [OPTIONS] database [tables]

4. The following parameters are added to the command line for starting the mysql database to enable the newly released mysql data tables to use transactions by default (
Only the create statement is affected .)
-- Default-table-type = InnoDB

Test command:
Use test;
Drop table if exists tn;
Create table tn (a varchar (10 ));
Show create table tn;

5. You can temporarily change the default table Type:
Set table_type = InnoDB;
Show variables like 'table _ type ';
Or:
C:/mysql/bin/mysqld-max-nt -- standalone -- default-table-type = InnoDB

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.