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

问题描述 投票:3回答:3

我想使用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;
mysql database innodb myisam
3个回答
0
投票

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

ALTER TABLE t1 ENGINE=InnoDB;

edit:哦,等等,您生成了这种语句,但是它们不起作用?


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

© www.soinside.com 2019 - 2024. All rights reserved.