mysql innodb myisam 表格式互转

innodb 转换为 myisam

SELECT  CONCAT('ALTER TABLE ', table_name, ' ENGINE=MyISAM;') AS sql_statements  INTO OUTFILE '/tmp/result.txt'
FROM    information_schema.tables AS tb
WHERE   table_schema = 'TableName'
AND     `ENGINE` = 'InnoDB'
AND     `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;

source /tmp/result.txt;

myisam 转换为 innodb

SELECT  CONCAT('ALTER TABLE ', table_name, ' ENGINE=InnoDB;') AS sql_statements  INTO OUTFILE '/tmp/result.txt'
FROM    information_schema.tables AS tb
WHERE   table_schema = 'TableName'
AND     `ENGINE` = 'MyISAM'
AND     `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;

source /tmp/result.txt;

发表评论

电子邮件地址不会被公开。 必填项已用*标注