Coming soon, fast templates with an unlimited number of modules for 1 UAH/order

How to convert all tables to MyISAM for the online shop {SEO-Shop}, OpenCart 2.x, 3.x, ocStore

When it comes to online shop, more preferably MyISAM engine, as 99% of transactions is the reading of the tables. But sometimes, for whatever reason, can be specified the InnoDB engine when creating tables for your module, and then have to manually fix it.

In order to save time you can use a software solution that will transfer all tables to MyISAM in one click:

DROP PROCEDURE IF EXISTS convertToMyIsam

In order to save time, you can use a software solution that will translate all the tables in MyISAM in one click:

DROP PROCEDURE IF EXISTS convertToMyIsam;

DELIMITER //

CREATE PROCEDURE convertToMyIsam ()

BEGIN

mainloop: LOOP

  SELECT TABLE_NAME INTO @convertTable FROM information_schema.TABLES

  WHERE `TABLE_SCHEMA` LIKE DATABASE ()

  AND `ENGINE` LIKE 'InnoDB' ORDER BY TABLE_NAME LIMIT 1;

  IF @convertTable IS NULL THEN

    LEAVE mainloop;

  END IF;

  SET @sqltext: = CONCAT ('ALTER TABLE ``, DATABASE (),' '.``, @convertTable,' 'ENGINE = MyISAM');

  PREPARE convertTables FROM @sqltext;

  EXECUTE convertTables;

  DEALLOCATE PREPARE convertTables;

  SET @convertTable = NULL;

END LOOP mainloop;

END //

DELIMITER;

CALL convertToMyIsam ();

DROP PROCEDURE IF EXISTS convertToMyIsam;

If you prefer to use InnoDB and you are burdened by the presence of MyISAM tables, then you can use the reverse script:

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;