The MEMORY storage engine uses the content in MEMORY to create tables. Each Memory table is actually associated with a disk file. The file name is in the format of "table name frm. Memory tables have extremely fast access. Because the data source comes from the Memory, when the database is disabled, the mysql storage engine in the Memory (2)
Mysql storage engine 2 memory merge BerkeleyDB storage engine
MEMORY
The MEMORY storage engine uses the content in MEMORY to create tables. Each Memory table is actually associated with a disk file. The file name is in the format of "table name. frm. Memory tables have extremely fast access. Because the data source comes from the Memory, when the database is disabled, data in the Memory will be lost. Hash indexes are used by default.
mysql> create table memory_table( id int primary key, name varchar(20) )engine=memory;Query OK, 0 rows affected (0.02 sec)mysql> insert into memory_table(id,name) values(2,'frank');Query OK, 1 row affected (0.00 sec)mysql> select * from memory_table;+----+-----------+| id | name |+----+-----------+| 1 | frankstar || 2 | frank |+----+-----------+2 rows in set (0.00 sec)mysql> show table status like 'memory_table' \G;*************************** 1. row *************************** Name: memory_table Engine: MEMORY Version: 10 Row_format: Fixed Rows: 2 Avg_row_length: 66 Data_length: 127008Max_data_length: 12582900 Index_length: 126992 Data_free: 0 Auto_increment: NULL Create_time: 2016-05-09 22:23:47 Update_time: NULL Check_time: NULL Collation: utf8_bin Checksum: NULL Create_options: Comment:1 row in set (0.00 sec)ERROR:No query specifiedmysql> show index from memory_table \G;*************************** 1. row *************************** Table: memory_table Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: id Collation: NULL Cardinality: 2 Sub_part: NULL Packed: NULL Null: Index_type: HASH Comment:Index_comment:1 row in set (0.00 sec)ERROR:No query specified
The memory of the memory table is stored in the memory. If the table has a large amount of data, the server automatically converts it to a disk table. The threshold value is determined by the temp_table_size system variable. The capacity of each memory table is controlled by the value of the max_heap_table_size variable. The default value is 16 MB.
It is mainly used for code tables with less frequent changes in data content and scenarios with high access speed requirements and a small amount of data. At the same time, it is necessary to consider that update operation data is not written back to disk files.
MERGE
It is actually a combination of a group of myisam tables. It combines a group of MyISAM tables with the same structure. The MERGE table itself has no data, and the insert operation for this type of table, the value is defined by INSERT_METHOD. The value is LAST or FIRST. "FIRST" means that the data is added to the FIRST myisam table in the composite table. Similarly, "LAST" means that the data is added to the LAST table. Therefore, there are two files in the MERGE table, one is the. frm file, used to store data, and the other MRG file, used to store the name of the MERGE table, including its composition table.
As follows:
mysql> create table myisam_table1( -> id int primary key, -> data datetime -> )engine=myisam;Query OK, 0 rows affected (0.02 sec)create table myisam_table2( id int primary key, data datetime )engine=myisam;Query OK, 0 rows affected (0.01 sec)mysql> create table table1_merge_table2( -> id int primary key, -> data datetime -> )engine=merge union=(myisam_table1,myisam_table2) insert_method=first;Query OK, 0 rows affected (0.01 sec)
Add data to the two Word tables as follows:
mysql> insert into myisam_table1 values(1,'2016-5-7');Query OK, 1 row affected (0.00 sec)mysql> insert into myisam_table1 values(2,'2016-5-6');Query OK, 1 row affected (0.00 sec)mysql> insert into myisam_table2 values(1,'2016-5-7');Query OK, 1 row affected (0.00 sec)mysql> insert into myisam_table2 values(2,'2016-5-6');Query OK, 1 row affected (0.00 sec)
Query the merge table as follows:
mysql> select * from table1_merge_table2;+----+---------------------+| id | data |+----+---------------------+| 1 | 2016-05-07 00:00:00 || 2 | 2016-05-06 00:00:00 || 1 | 2016-05-07 00:00:00 || 2 | 2016-05-06 00:00:00 |+----+---------------------+4 rows in set (0.01 sec)
Add a data entry to the merge table as follows:
mysql> insert into table1_merge_table2 values(3,'2016-5-8');Query OK, 1 row affected (0.00 sec)mysql> select * from table1_merge_table2;+----+---------------------+| id | data |+----+---------------------+| 1 | 2016-05-07 00:00:00 || 2 | 2016-05-06 00:00:00 || 3 | 2016-05-08 00:00:00 || 1 | 2016-05-07 00:00:00 || 2 | 2016-05-06 00:00:00 |+----+---------------------+5 rows in set (0.00 sec)mysql> select * from myisam_table1;+----+---------------------+| id | data |+----+---------------------+| 1 | 2016-05-07 00:00:00 || 2 | 2016-05-06 00:00:00 || 3 | 2016-05-08 00:00:00 |+----+---------------------+3 rows in set (0.00 sec)mysql> select * from myisam_table2;+----+---------------------+| id | data |+----+---------------------+| 1 | 2016-05-07 00:00:00 || 2 | 2016-05-06 00:00:00 |+----+---------------------+2 rows in set (0.00 sec)
The specified INSERT_METHOD takes effect. If it is not specified, an error will occur when you try to insert data to the Merge table. Generally, merge tables are used to transparently query and update multiple tables.
BerkeleyDB storage engine
BDB for short. When creating a table of this type, there will be two data files, one. frm file to store table metadata, and the other. db file to store data and index files, similar to innodb. Its implementation of transaction security includes redo logs. At each startup, a check operation is performed to clear all redo logs. Like the Memory engine, it is page-level locking.