Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Optimize All Tables In A MySQL Database

Sun Oct 26, 2008 6:13 pm

If you have a database driven site and you want to optimize MySQL tables then this is perfect. It goes through all the tables in a MySQL database and does table optimization on each one using the MySQL Optimize Table syntax.

Code:

<?php



dbConnect
()



$alltables = mysql_query("SHOW TABLES");



while (
$table = mysql_fetch_assoc($alltables))

{



   foreach (
$table as $db => $tablename)

   {

       
mysql_query("OPTIMIZE TABLE '".$tablename."'")

           or die(
mysql_error());

   }

   

}



?>





Post a reply
  Related Posts  to : Optimize All Tables In A MySQL Database
 Database Cashing tables results model     -  
 dump Mysql database     -  
 import Mysql database     -  
 Creating a Database in MySQL     -  
 IP Address Lookup in Bulk Using C-Sharp and MySQL Database     -  
 Add two tables     -  
 Generating Tables from XML by php     -  
 Persisting a class into two tables     -  
 need help in mysql     -  
 connect to MYSQL from ASP     -  

Topic Tags

PHP Database