Forked from teodorboev/gist:c3f125c1fd8b2b829d99672c0d686362
Created
September 8, 2018 10:09
-
-
Save codeagencybe/92a7e2330e33cfde022b7749569d89d7 to your computer and use it in GitHub Desktop.
Wordpress MySQL table converter to InnoDB
This file contains hidden or 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
DROP PROCEDURE IF EXISTS convertToInnodb; | |
DELIMITER // | |
CREATE PROCEDURE convertToInnodb() | |
BEGIN | |
mainloop: LOOP | |
SELECT TABLE_NAME INTO @convertTable FROM information_schema.TABLES | |
WHERE `TABLE_SCHEMA` LIKE DATABASE() | |
AND `ENGINE` LIKE 'MyISAM' ORDER BY TABLE_NAME LIMIT 1; | |
IF @convertTable IS NULL THEN | |
LEAVE mainloop; | |
END IF; | |
SET @sqltext := CONCAT('ALTER TABLE `', DATABASE(), '`.`', @convertTable, '` ENGINE = INNODB'); | |
PREPARE convertTables FROM @sqltext; | |
EXECUTE convertTables; | |
DEALLOCATE PREPARE convertTables; | |
SET @convertTable = NULL; | |
END LOOP mainloop; | |
END// | |
DELIMITER ; | |
CALL convertToInnodb(); | |
DROP PROCEDURE IF EXISTS convertToInnodb; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment