Comando MySQL che interroga tutto il database MyISAM


13

Gradirei se qualcuno potesse aiutarmi su qual è il comando corretto in MySQL per interrogare tutto il database per avere il motore "MyISAM". Devo convertire tutti i DB e le tabelle da MyISAM a InnoDB.

Risposte:


25

Di seguito è la query per trovare tutte le tabelle che hanno MyISAMEngine

SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine FROM information_schema.TABLES WHERE ENGINE='MyISAM' AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');

Query sopra elencherà tutte le tabelle con MyISAMEngine.

Per come convertire le tabelle MyISAM esistenti in InnoDB Di seguito è la query che restituirà le istruzioni ALTER in cui convertire le MyISAMtabelle esistenti InnoDB.

SELECT CONCAT('ALTER TABLE `', TABLE_SCHEMA,'`.`',TABLE_NAME, '` ENGINE = InnoDB;') FROM information_schema.TABLES WHERE ENGINE='MyISAM' AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');

È possibile eseguire queste istruzioni per convertire i motori.


Grazie @AbdulManaf. Non mi aspettavo che il primo comando avrebbe richiesto tempo sul server.
— James Wise,

Sì, non dovrebbe richiedere tempo.
— Abdul Manaf,

Come eseguire una query per trovare tutte le tabelle nei database che non sono InnoDB?
— James Wise,
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.