Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Alter Table Engine = InnoDB be run on multiple tables at the same time?

When it comes to MySQL and PHPMyAdmin, I'm not a novice, but I'm closer to novice than expert. Hopefully what I ask for is doable, and that someone will provide me with a simple, cut-n-paste SQL query to make it happen.

I need to convert around 9 tables in each of 12 dbs from MyISAM to InnoDB, and I'm hoping I can do all the tables in one db with a single query rather than having to click-and-wait for each and every table in PHPMyAdmin. Basically, is there a way to run "ALTER TABLE foo ENGINE = InnoDB" on multiple tables at once via a query run in PHPMyAdmin?

like image 763
iampariah Avatar asked Jun 11 '11 19:06

iampariah


1 Answers

select concat('alter table ',table_name, ' engine = innodb;')
from information_schema.tables
where table_schema in ('db1','db2',....,'dbN')

then run the query output.

like image 55
Nicola Cossu Avatar answered Oct 07 '22 19:10

Nicola Cossu