Created
March 27, 2014 16:17
-
-
Save chicks/9811377 to your computer and use it in GitHub Desktop.
Convert from MyISAM to InnoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sql = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='%s' AND engine='MyISAM' AND table_name NOT IN (SELECT table_name FROM INFORMATION_SCHEMA.statistics WHERE index_type='FULLTEXT' AND table_schema='%s')"; | |
$result = $db->query(sprintf($sql, | |
mysql_escape_string($instance->getName()), | |
mysql_escape_string($instance->getName()) | |
)); | |
while ($row = $db->fetch_array($result)) { | |
$tables[] = $row[0]; | |
} | |
foreach ($tables as $table) { | |
if (in_array($table, $skip_tables)) { | |
continue; | |
} | |
$sql = sprintf("ALTER TABLE %s ENGINE=InnoDB", mysql_escape_string($table)); | |
syslog(LOG_NOTICE, sprintf("converting %s.%s to InnoDB", $instance->getDbName(), $table)); | |
if (!$db->query($sql)) { | |
syslog(LOG_NOTICE, sprintf("conversion of %s.%s failed because: '%s'", | |
$instance->getName(), | |
$table, | |
$db->geterrdesc())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment