简体   繁体   中英

Alter all database tables engine to InnoDB

I want to use an sql query, to alter all my database tables engine from MyISAM to InnoDB.
I used the query below. Although it gives me a success message, it doesn t work. Still my table s Storage Engine is MyISAM.

SELECT CONCAT('ALTER TABLE ', table_name, ' ENGINE=InnoDB;') as ExecuteTheseSQLCommands
FROM information_schema.tables WHERE table_schema = 'name_of_the_database' 
ORDER BY table_name DESC;

My solution - launch your mysql shell and paste:

SELECT CONCAT('ALTER TABLE ',CONCAT(TABLE_SCHEMA,'.',TABLE_NAME),'     
ENGINE=InnoDB;') 
FROM INFORMATION_SCHEMA.TABLES
WHERE ENGINE='MyISAM'
AND TABLE_SCHEMA NOT IN ('MYSQL','INFORMATION_SCHEMA','PERFORMANCE_SCHEMA','SYS')
INTO OUTFILE '/tmp/mysql.conversions';
SOURCE /tmp/mysql.conversions;

Source 1: https://computingforgeeks.com/how-to-convert-all-mysql-tables-from-myisam-into-innodb-storage-engine/

Source 2: https://stackoverflow.com/a/16014411/3882707

See http://dev.mysql.com/doc/refman/5.0/en/converting-tables-to-innodb.html

ALTER TABLE t1 ENGINE=InnoDB;

edit : oh wait, you generated this kind of statements, but they did not work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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