Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
Last active August 29, 2015 14:21
Show Gist options
  • Save cesarkohl/89bfb524b894e2ebf3c4 to your computer and use it in GitHub Desktop.
Save cesarkohl/89bfb524b894e2ebf3c4 to your computer and use it in GitHub Desktop.
MySQL - MyISAM to InnoDB
// Run this SQL statement (in the mysql client, phpMyAdmin, or wherever) to retrieve all the MyISAM tables in your database.
// Replace value of the name_of_your_db variable with your database name.
// Then, copy the output and run as a new SQL query.
SET @DATABASE_NAME = 'name_of_your_db';
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'MyISAM'
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment