[英]MySQL MERGE Storage Engine
I am setting up a table in mysql of engine type merge in mysql and was wondering if i have to have all my tables created previously that i want to merge. 我在mysql中建立一个mysql引擎类型合并的表,并且想知道我是否必须先创建我想要合并的所有表。 For example:
例如:
CREATE TABLE t1 (
a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
message CHAR(20)) ENGINE=MyISAM;
CREATE TABLE t2 (
a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
message CHAR(20)) ENGINE=MyISAM;
INSERT INTO t1 (message) VALUES ('Testing'),('table'),('t1');
INSERT INTO t2 (message) VALUES ('Testing'),('table'),('t2');
CREATE TABLE total (
a INT NOT NULL AUTO_INCREMENT,
message CHAR(20), INDEX(a))
ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
Now if i have code that automatically created a t3 table i would have to modify the merge table to add this to the union? 现在,如果我有自动创建t3表的代码,我将不得不修改合并表以将其添加到联合? Would i use an ALTER query for that?
我会使用ALTER查询吗?
note: i am not using MySQL partitions because i have a mysql version 5.0. 注意:我没有使用MySQL分区,因为我有一个mysql版本5.0。
Now if i have code that automatically created a t3 table i would have to modify the merge table to add this to the union?
现在,如果我有自动创建t3表的代码,我将不得不修改合并表以将其添加到联合? Would i use an ALTER query for that?
我会使用ALTER查询吗?
From the documentation : 从文档 :
To remap a
MERGE
table to a different collection ofMyISAM
tables, you can use one of the following methods:要将
MERGE
表重新映射到不同的MyISAM
表集合,可以使用以下方法之一:
DROP
theMERGE
table and re-create it.DROP
MERGE
表并重新创建它。- Use
ALTER TABLE tbl_name UNION=(...)
to change the list of underlying tables.使用
ALTER TABLE tbl_name UNION=(...)
更改基础表的列表。Beginning with
MySQL
5.0.60, it is also possible to use ALTER TABLE ... UNION=()
(that is, with an emptyUNION
clause) to remove all of the underlying tables.从
MySQL
5.0.60开始,也可以使用ALTER TABLE ... UNION=()
(即使用空的UNION
子句)来删除所有基础表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.