Reference a section in the MySQL official document: the MERGE storage engine, also known as the MRG_MyISAM engine, is a set of identical MyISAM tables that can be used as one.
Reference a section in the MySQL official document: the MERGE storage engine, also known as the MRG_MyISAM engine, is a set of identical MyISAM tables that can be used as one.
Introduction:
Reference a section in the MySQL official document: the MERGE storage engine, also known as the MRG_MyISAM engine, is a set of identical MyISAM tables that can be used as one. "same" means that all tables share the same column and index information. you cannot merge the tables in which columns are not in the same sequence. Tables without exactly the same columns or tables with different order indexes are not allowed. in addition, any or all tables can be compressed using myisampack.
Example:
Mysql> show engines;
+ -------------------- + --------- + ---------------------------------------------------------------- + ------------ +
| Engine | Support | Comment | Transactions | XA | Savepoints |
+ -------------------- + --------- + ---------------------------------------------------------------- + ------------ +
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO |
| MyISAM | YES | MyISAM storage engine | NO |
| BLACKHOLE | YES |/dev/null storage engine (anything you write to it disappears) | NO |
| CSV | YES | CSV storage engine | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO |
| ARCHIVE | YES | Archive storage engine | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES |
+ -------------------- + --------- + ---------------------------------------------------------------- + ------------ +
9 rows in set (0.00 sec)
Mysql> create table test1 (id int not null auto_increment, name varchar (10) default null, primary key (id) engine = myisam auto_increment = 1;
Query OK, 0 rows affected (0.01 sec)
Mysql> create table test2 (id int not null auto_increment, name varchar (10) default null, primary key (id) engine = myisam auto_increment = 1;
Query OK, 0 rows affected (0.00 sec)
Mysql> insert into 'test1' ('name') VALUES ('beijing1 ');
Query OK, 1 row affected (0.00 sec)
Mysql> insert into 'test2' ('name') VALUES ('beijing2 ');
Query OK, 1 row affected (0.00 sec)
Mysql> create table test (id int not null auto_increment, name varchar (10) default null, index (id) engine = mrg_myisam union = (test1, test2) insert_method = last auto_increment = 1;
Query OK, 0 rows affected (0.03 sec)
Mysql> select id, name from test;
+ ---- + ---------- +
| Id | name |
+ ---- + ---------- +
| 1 | beijing1 |
| 1 | beijing2 |
+ ---- + ---------- +
2 rows in set (0.00 sec)
Mysql> insert into 'test' ('name') VALUES ('beijinging3 ');
Query OK, 1 row affected (0.00 sec)
Mysql> select id, name from test;
+ ---- + ---------- +
| Id | name |
+ ---- + ---------- +
| 1 | beijing1 |
| 1 | beijing2 |
| 2 | beijing3 |
+ ---- + ---------- +
3 rows in set (0.00 sec)