! rm -f /tmp/ivan_alter.sql #預刪除臨時文件,方式下面的語句無法寫入
代碼如下 復制代碼
SELECT concat(‘alter table `’, TABLE_SCHEMA, ‘`.`’, TABLE_NAME, ‘` engine=innodb;’)
FROM information_schema.TABLES
WHERE ENGINE=‘Myisam’ AND
TABLE_SCHEMA<>‘mysql’ AND
TABLE_SCHEMA<>‘information_schema’
INTO OUTFILE ‘/tmp/ivan_alter.sql’ ;
source /tmp/ivan_alter.sql
! rm -f /tmp/ivan_alter.sql
#執行完後刪除臨時文件