简体   繁体   English

如何仅将共享相似前缀的表的存储引擎从MyISAM更改为innoDB?

[英]How can I change the storage engine from MyISAM to innoDB only for tables sharing a similar prefix?

Using phpmyadmin I have several tables with the same prefix. 使用phpmyadmin我有几个具有相同前缀的表。 I know I can change the storage engine one table by one table, but since some tables are quite heavy to process loading takes forever and sometimes crashes. 我知道我可以一个表一个表地更改存储引擎,但是由于某些表非常繁重,因此处理加载需要花费很多时间,并且有时会崩溃。

Is there a way to select several tables without using the full table name, and then change the storage engine from MyISAM to innoDB for the selected tables ? 有没有一种方法可以选择多个表而不使用完整的表名,然后将所选表的存储引擎从MyISAM更改为innoDB?

phpmyadmin has a window for executing commands. phpmyadmin有一个用于执行命令的窗口。 (Better yet, use mysql commandline tool.) (更好的是,使用mysql命令行工具。)

Step 1: Generate the ALTERs : 步骤1:生成ALTERs

SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' ENGINE=InnoDB;')
   FROM information_schema.TABLES
   WHERE table_schema='test' AND ENGINE='MyISAM' AND TABLE_NAME LIKE 'rj%';
+-------------------------------------------------------+
| CONCAT('ALTER TABLE ', TABLE_NAME, ' ENGINE=InnoDB;') |
+-------------------------------------------------------+
| ALTER TABLE rj_article ENGINE=InnoDB;                 |
| ALTER TABLE rj_blobs ENGINE=InnoDB;                   |
| ALTER TABLE rj_bodies ENGINE=InnoDB;                  |
| ALTER TABLE rj_combos ENGINE=InnoDB;                  |
| ALTER TABLE rj_contents ENGINE=InnoDB;                |
| ALTER TABLE rj_current ENGINE=InnoDB;                 |

... ...

Step 2: 第2步:

Execute those by copying them. 通过复制来执行它们。 Note: Since phpmyadmin has some kind of time limit, either raise that limit, or switch to mysql commandline tool. 注意:由于phpmyadmin具有某种时间限制,因此可以提高该限制,或者切换到mysql命令行工具。

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

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