批量修改存储引擎

2021-08-26  本文已影响0人  这货不是王马勺

我们目的是都改为innodb
所以先查找一下所有非innodb的表:

select table_catalog
      ,table_schema
      ,table_name
      ,engine
from information_schema.tables
where engine<>'InnoDB'
and table_schema not in ('mysql','information_schema','performance_schema');

利用字符串拼接语句:

select concat('alter table ',table_name,' engine=innodb;')
from information_schema.tables
where engine <> 'InnoDB'
and table_schema = '库名';

然后将结果集复制出来执行即可

上一篇 下一篇

猜你喜欢

热点阅读