05, 09 2010, 08:34:30 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Weztec home  
Pages: [1]   Go Down
  Print  
Author Topic: MySQL: Optimize Tables  (Read 3392 times)
0 Members and 1 Guest are viewing this topic.
Weztec Support Team
Administrator
Newbie
*****
Offline Offline

Posts: 38



View Profile
« on: 18, 02 2007, 09:43:57 PM »

Code:
<?php

$host
="Host";
$username="Username";
$password="Password";
$db_name="Database Name";
$tbl_name="Table Name";

mysql_connect("$host""$username""$password")or die("Cannot connect");
mysql_select_db("$db_name")or die("Cannot select database");

$tables mysql_query("SHOW TABLES");

while (
$table mysql_fetch_assoc($tables))
{

   foreach (
$table as $db => $tablename)
   {
       
mysql_query("OPTIMIZE TABLE '".$tablename."'") or die(mysql_error());
   }
   
}

?>

Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.252 seconds with 20 queries.