Thursday 30 October 2014

How to Convert Tables 'MyISAM' to 'InnoDB' Engine in mysql database


-- QUERY TO CONVERT TABLES 'MyISAM' to 'InnoDB' Engine

SET @DATABASE_NAME = 'database';

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;


-- QUERY TO CONVERT TABLES 'InnoDB' TO 'MyISAM' ENGINE


SET @DATABASE_NAME = 'database';

SELECT  CONCAT('ALTER TABLE ', table_name, ' ENGINE=MyISAM;') AS sql_statements
FROM    information_schema.tables AS tb
WHERE   table_schema = @DATABASE_NAME
AND     `ENGINE` = 'InnoDB'
AND     `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;



1 comment:

  1. Hi, can you please upload php mvc framework with example... i am a basic php developer

    ReplyDelete