Di seguito la procedura per eseguire la modifica dell’Engine per le tabelle presenti nel nostro DB (in questo esempio modificheremo l’Engine da MyISAM a InnoDB). La procedura non è automatica, occorre svolgerla in più passaggi.
Collegarsi al MySQL e al nostro DB:
mysql -u pippo -p pippodb
Eseguire la seguente query:
SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' engine=InnoDB;') FROM information_schema.tables WHERE engine = "MyISAM" AND table_type = "BASE TABLE" AND table_schema NOT IN ('mysql');
La query restituirà l’elenco delle tabelle che hanno attualmente l’Engine settato a MyISAM e produrrà come output le nuove query da copiare e incollare per effettuale la reale modifica:
ALTER TABLE pippodb.tabella1 engine=InnoDB; ALTER TABLE pippodb.tabella2 engine=InnoDB; ALTER TABLE pippodb.tabella3 engine=InnoDB; ALTER TABLE pippodb.tabella4 engine=InnoDB;
Copiate l’estrazione e usatela nuovamente come se fosse una query.
L’operazione è conclusa.
SELECT CONCAT(‘ALTER TABLE ‘,table_schema,’.’,table_name,’ engine=InnoDB;’) FROM information_schema.tables WHERE engine = “MyISAM”AND table_type = “BASE TABLE”AND table_schema NOT IN (‘mysql’,’phpmyadmin’) – See more at: http://coldfusionbeyond.com/post.cfm/quick-changing-the-mysql-engine-on-existing-tables#sthash.1Y21rWRc.dpuf
SELECT CONCAT(‘ALTER TABLE ‘,table_schema,’.’,table_name,’ engine=InnoDB;’) FROM information_schema.tables WHERE engine = “MyISAM”AND table_type = “BASE TABLE”AND table_schema NOT IN (‘mysql’,’phpmyadmin’) – See more at: http://coldfusionbeyond.com/post.cfm/quick-changing-the-mysql-engine-on-existing-tables#sthash.1Y21rWRc.dpuf
SELECT CONCAT(‘ALTER TABLE ‘,table_schema,’.’,table_name,’ engine=InnoDB;’) FROM information_schema.tables WHERE engine = “MyISAM”AND table_type = “BASE TABLE”AND table_schema NOT IN (‘mysql’,’phpmyadmin’) – See more at: http://coldfusionbeyond.com/post.cfm/quick-changing-the-mysql-engine-on-existing-tables#sthash.1Y21rWRc.dpuf