// Parametri iniziali // user, pwd dbName. $server = localhost; $user = mysql_user; $pwd = mysql_password; $dbName = mysql_dbName; $link = mysql_connect($server, $user, $pwd); if (!$link) { die(‘Impossibile connettersi: ‘ . mysql_error()); } $db_selected = mysql_select_db($dbName, $link); if (!$db_selected) { die (‘Selezione DB $dbName non riuscita: ‘ . mysql_error()); } // Estrae tutti i nomi di tabella. $alltables = mysql_query(“SHOW TABLES”); // Sfoglia le tabelle. while ($table = mysql_fetch_assoc($alltables)) { foreach ($table as $db => $tablename) { // Per ogni tabella esegue la query di ottimizzazione. mysql_query(“OPTIMIZE TABLE ‘”.$tablename.”‘”) or die(mysql_error()); } } mysql_close($link); ==><==
]]>
Nessun commento “Mysql e ottimizzazione tabelle”
Alle volte può succedere che le tabelle si corrompino dopo aver fatto l’operazione di ottimizzazione, a tal proposito fate riferimento all’articolo:
https://www.etechs.it/mysql-errno-144-repair-tablephp/