MERGE

Descrição:

O mecanismo de armazenamento MERGE, também conhecido como mecanismo MRG_MyISAM, é uma coleção de tabelas MyISAM idênticas que podem ser usadas como uma só. "Idênticas" significa que todas as tabelas possuem informação idêntica de colunas e índices. Você não pode mesclar tabelas MySAM onde as colunas estejam listadas numa ordem diferente, não tenham exatamente as mesmas colunas, ou tenham os índices numa ordem diferente. No entanto, qualquer ou todas as tabelas MyISAM podem ser comprimidas com myisampack. Veja http://dev.mysql.com/doc/refman/5.1/en/myisampack.html. As diferenças entre as opções de tabela tais como AVG_ROW_LENGTH, MAX_ROWS, ou PACK_KEYS não importam.

Exemplos:

MariaDB [test]> CREATE TABLE t1 (
    ->    a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    ->    message CHAR(20)) ENGINE=MyISAM;
Query OK, 0 rows affected (0.10 sec)

MariaDB [test]> CREATE TABLE t2 (
    ->    a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    ->    message CHAR(20)) ENGINE=MyISAM;
Query OK, 0 rows affected (0.16 sec)

MariaDB [test]> INSERT INTO t1 (message) VALUES ('Testing'),('table'),('t1');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

MariaDB [test]> INSERT INTO t2 (message) VALUES ('Testing'),('table'),('t2');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

MariaDB [test]> CREATE TABLE total (
    ->    a INT NOT NULL AUTO_INCREMENT,
    ->    message CHAR(20), INDEX(a))
    ->    ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
Query OK, 0 rows affected (0.10 sec)

MariaDB [test]> select * from total;
+---+---------+
| a | message |
+---+---------+
| 1 | Testing |
| 2 | table   |
| 3 | t1      |
| 1 | Testing |
| 2 | table   |
| 3 | t2      |
+---+---------+
6 rows in set (0.00 sec)

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.