56,679
社区成员
发帖
与我相关
我的任务
分享
mysql> CREATE TABLE t1 (
-> a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> f int,
-> message CHAR(20),
-> index (f)) ENGINE=MyISAM;
Query OK, 0 rows affected (0.02 sec)
mysql> CREATE TABLE t2 (
-> a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> f int,
-> message CHAR(20),
-> index (f)) ENGINE=MyISAM;
Query OK, 0 rows affected (0.05 sec)
mysql> CREATE TABLE total (
-> a INT NOT NULL AUTO_INCREMENT,
-> f int,
-> message CHAR(20), INDEX(a),index(f))
-> ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
Query OK, 0 rows affected (0.06 sec)
mysql> select * from t1;
+---+------+---------+
| a | f | message |
+---+------+---------+
| 1 | 1 | Testing |
| 2 | 2 | table |
| 3 | 3 | t1 |
+---+------+---------+
3 rows in set (0.00 sec)
mysql> select * from t2;
+---+------+---------+
| a | f | message |
+---+------+---------+
| 1 | 1 | Testing |
| 2 | 2 | table |
| 3 | 3 | t2 |
+---+------+---------+
3 rows in set (0.00 sec)
mysql> select * from total;
+---+------+---------+
| a | f | message |
+---+------+---------+
| 1 | 1 | Testing |
| 2 | 2 | table |
| 3 | 3 | t1 |
| 1 | 1 | Testing |
| 2 | 2 | table |
| 3 | 3 | t2 |
+---+------+---------+
6 rows in set (0.00 sec)
mysql>