MySQL: Mass Conversion Script for Table Engine

368 views Asked by At

I'm trying to figure out how to convert en mass from database table engine A to table engine B (in this case, from MyISAM to InnoDB). I know I can do it for individual tables using the MySQL workbench, but i'd like a script or a program that can do the conversion en mass. Anyone got any ideas?

* EDIT * I'd prefer an SQL query that I could use to do this, without using php, if possible.

1

There are 1 answers

3
ircmaxell On BEST ANSWER

In pseudo code using information_schema tables:

$rows = "SELECT TABLE_NAME 
    FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_SCHEMA = 'yourDBName'
        AND ENGINE LIKE 'engineA'";
foreach ($rows as $table) {
    $query = 'ALTER TABLE '.$table.' ENGINE = engineB';
}