top of page
CerebroSQL

MySQL: 

MERGE

The MERGE storage engine, also known as the MRG_MyISAM engine, is a
collection of identical MyISAM tables that can be used as one.
"Identical" means that all tables have identical column data types and
index information. You cannot merge MyISAM tables in which the columns
are listed in a different order, do not have exactly the same data
types in corresponding columns, or have the indexes in different order.
However, any or all of the MyISAM tables can be compressed with
myisampack. Differences between tables such as these do not matter:

o Names of corresponding columns and indexes can differ.

o Comments for tables, columns, and indexes can differ.

o Table options such as AVG_ROW_LENGTH, MAX_ROWS, or PACK_KEYS can
differ.

Example

mysql> CREATE TABLE t1 (
-> a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> message CHAR(20)) ENGINE=MyISAM;
mysql> CREATE TABLE t2 (
-> a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> message CHAR(20)) ENGINE=MyISAM;
mysql> INSERT INTO t1 (message) VALUES ('Testing'),('table'),('t1');
mysql> INSERT INTO t2 (message) VALUES ('Testing'),('table'),('t2');
mysql> CREATE TABLE total (
-> a INT NOT NULL AUTO_INCREMENT,
-> message CHAR(20), INDEX(a))
-> ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;

bottom of page