将所有数据库表引擎更改为InnoDB

时间:2013-01-22 16:55:21

标签: mysql database innodb myisam

我想使用sql查询,将我的所有数据库表引擎从MyISAM改为InnoDB 我使用了下面的查询。虽然它给了我一个成功的信息,但它不起作用。我的桌面存储引擎仍然是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;

3 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

我的解决方案-启动mysql shell并粘贴:

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;

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

来源2:https://stackoverflow.com/a/16014411/3882707

答案 2 :(得分:0)

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

ALTER TABLE t1 ENGINE=InnoDB;

编辑:哦等等,你生成了这种语句,但它们没有用?