美文网首页
一键修改MySql表引擎

一键修改MySql表引擎

作者: 孑然自安 | 来源:发表于2019-06-27 10:34 被阅读0次

    有个新项目在建表的时候疏忽了表类型,做事务的时候想起来表引擎需要为“InnoDB ”,就稍微折腾了下。
    一键方法参上!

    首先选中数据库,执行。

    SELECT CONCAT('ALTER TABLE ',table_name,' ENGINE=InnoDB;') FROM information_schema.tables
    WHERE table_schema='db_name' AND ENGINE='MyISAM';
    

    此sql会生成一排语句

    ALTER TABLE wl_balance_log ENGINE=INNODB;
    ALTER TABLE wl_cemetery ENGINE=INNODB;
    ALTER TABLE wl_cemetery_access_records ENGINE=INNODB;
    ALTER TABLE wl_cemetery_leave_message ENGINE=INNODB;
    ALTER TABLE wl_cemetery_tree ENGINE=INNODB;
    ALTER TABLE wl_cemetery_tree_growth_record ENGINE=INNODB;
    ALTER TABLE wl_cemetery_tree_level ENGINE=INNODB;
    ALTER TABLE wl_culturing_action ENGINE=INNODB;
    ALTER TABLE wl_gift ENGINE=INNODB;
    ALTER TABLE wl_gift_category ENGINE=INNODB;
    ALTER TABLE wl_gift_order_log ENGINE=INNODB;
    ALTER TABLE wl_gift_spec ENGINE=INNODB;
    ALTER TABLE wl_grave_no ENGINE=INNODB;
    ALTER TABLE wl_grave_no_rule ENGINE=INNODB;
    ALTER TABLE wl_lisi_group ENGINE=INNODB;
    ALTER TABLE wl_lisi_relation ENGINE=INNODB;
    ALTER TABLE wl_memorial_hall ENGINE=INNODB;
    ALTER TABLE wl_memorial_hall_type ENGINE=INNODB;
    ALTER TABLE wl_memorial_type ENGINE=INNODB;
    ALTER TABLE wl_music ENGINE=INNODB;
    ALTER TABLE wl_recharge_log ENGINE=INNODB;
    ALTER TABLE wl_religion ENGINE=INNODB;
    ALTER TABLE wl_seed ENGINE=INNODB;
    ALTER TABLE wl_transfer_log ENGINE=INNODB;
    ALTER TABLE wl_user_seed ENGINE=INNODB;
    ALTER TABLE wl_warehouse ENGINE=INNODB;
    

    将语句复制后执行,即完成更改引擎操作。


    image.png

    相关文章

      网友评论

          本文标题:一键修改MySql表引擎

          本文链接:https://www.haomeiwen.com/subject/kmjlcctx.html