MYSQL three storage engines

1. InnoDB storage engine

InnoDB provides transaction processing , rollback , crash repair capabilities, and multi-version concurrency control transaction security for MySQL tables . Include InnnoDB in MySQL starting from 3.23.34a. It is the first table engine on MySQL that provides foreign key constraints. And InnoDB's ability to deal with transactions is also unmatched by other storage engines. The default storage engine for later versions of MySQL is InnoDB.

The InnoDB storage engine always supports AUTO_INCREMENT . The value of the auto-increment column cannot be empty, and the value must be unique. MySQL specifies that self-incrementing columns must be primary keys. When inserting a value, if the auto-increment column does not enter a value, the inserted value is the auto-incremented value; if the entered value is 0 or NULL, the inserted value is also the auto-incremented value; A certain value, and the value has not appeared before, can be directly inserted.

InnoDB also supports foreign keys (FOREIGN KEY) . The table where the foreign key is located is called the child table, and the table on which the foreign key depends (REFERENCES) is called the parent table. The fields in the parent table that are related to the foreign key of the word table must be the primary key. When deleting or updating a piece of information in the parent table, the child table must also be changed accordingly. This is the referential integrity rule of the database .

In InnoDB, the table structure of the created table is stored in the .frm file (I think it is the abbreviation of frame). Data and indexes are stored in the table spaces defined by innodb_data_home_dir and innodb_data_file_path.

InnoDB's advantage is that it provides good transaction processing, crash repair capabilities and concurrency control. The disadvantage is that the read and write efficiency is poor, and the data space occupied is relatively large.

2. MyISAM storage engine

MyISAM is a common storage engine in MySQL and used to be MySQL's default storage engine. MyISAM is developed based on the ISAM engine, adding many useful extensions.

MyISAM table is stored as 3 files. The file name is the same as the table name. The extension is named frm , MYD , MYI . In fact, the structure of the frm file storage table; MYD file storage data is an abbreviation of MYData; MYI file storage index is an abbreviation of MYIndex.

Tables based on the MyISAM storage engine support 3 different storage formats. Including static type, dynamic type and compression type. Among them, the static type is the default storage format of MyISAM, and its fields are of fixed length; the dynamic type contains variable-length fields, and the record length is not fixed; the compressed type requires the use of the myisampack tool, which takes up less disk space.

The advantages of MyISAM are its small footprint and fast processing speed. The disadvantage is that it does not support the integrity and concurrency of transactions.

3. MEMORY storage engine

MEMORY is a special type of storage engine in MySQL. It uses the content stored in memory to create tables, and the data is all placed in memory . These characteristics are very different from the previous two.

Each table based on the MEMORY storage engine actually corresponds to a disk file. The file name of the file is the same as the table name, and the type is frm type. Only the structure of the table is stored in this file. The data files are stored in memory, which is conducive to the rapid processing of data and improve the efficiency of the entire table. It is worth noting that the server needs to have enough memory to maintain the use of the MEMORY storage engine's tables. If it is no longer needed, you can free up memory and even delete unnecessary tables.

MEMORY uses hash indexes by default. It is faster than using a B-tree index. Of course, if you want to use the B-type tree index, you can specify it when creating the index.

Note that MEMORY is rarely used, because it is to store data in memory, if the memory is abnormal, it will affect the data. If you restart or shut down, all data will disappear. Therefore, the life cycle of a table based on MEMORY is very short, generally one-off.

(Reference:  https://www.cnblogs.com/icebutterfly/p/9553929.html     )

 

Guess you like

Origin www.cnblogs.com/0error0warning/p/12723936.html