简体   繁体   English

MySQL MERGE存储引擎 - DROP&ALTER

[英]MySQL MERGE Storage Engine - DROP & ALTER

I need to Add & Delete merged tables in the UNION=() line. 我需要在UNION =()行中添加和删除合并表。 According to the MySQL docs it says: 根据MySQL文档,它说:

  1. DROP the MERGE table and re-create it. DROP MERGE表并重新创建它。
  2. Use ALTER TABLE tbl_name UNION=(...) to change the list of underlying tables. 使用ALTER TABLE tbl_name UNION =(...)更改基础表的列表。

The only "DROP" I'm aware of is DROP TABLE tablename; 我所知道的唯一“DROP”是DROP TABLE tablename; Are these instructions suggesting that I drop the MRG_MyISAM table, then recreate it with an empty UNION=() field? 这些说明是否表明我删除了MRG_MyISAM表,然后使用空的UNION =()字段重新创建它? To then be followed by an ALTER TABLE tbl_name UNION=(...) with all the tables I need to have connected? 接下来是一个ALTER TABLE tbl_name UNION =(...),我需要连接所有表吗?

If possible, could you post an example of the commands? 如果可能的话,你能发布一个命令的例子吗?

Thanks 谢谢

Oh boy, am I late here. 哦,孩子,我来晚了。 But this page is in the top google search results for "alter table tbl_name union=(...)". 但是此页面位于“alter table tbl_name union =(...)”的google搜索结果中。 So I guess it needs an answer 所以我想它需要一个答案

So here's the answer. 所以这就是答案。 To change the union list of underlying tables for merge table you only need to execute this statement 要更改合并表的基础表的联合列表,您只需执行此语句

alter table tbl_name union=(`t1`,`t2`,`t3`);

where t1 , t2 , t3 is a list of tables you want to have in a union. 其中t1t2t3是您希望在联合中拥有的表的列表。

You can drop merge table and recreate it with a new list of underlying tables. 您可以删除合并表并使用新的基础表列表重新创建它。 Drop statement execute on merge table will only delete the merge table itself and won't affect underlying tables. 合并表上的drop语句执行只会删除合并表本身,不会影响基础表。

But altering it should be sufficient. 但改变它应该就足够了。 And you don't need to recreate it with empty union, if you ever do that, just use list of tables that you want to have in it. 并且您不需要使用空联合重新创建它,如果您这样做,只需使用您想要的表列表。

For more, please refer to documentation: 有关更多信息,请参阅文档:

https://dev.mysql.com/doc/refman/5.7/en/merge-storage-engine.html https://dev.mysql.com/doc/refman/5.7/en/merge-storage-engine.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM