Posted By

brent-man on 10/23/08


Tagged

mysql php table optimize


Versions (?)

Who likes this?

19 people have marked this snippet as a favorite

jamesming
Scooter
luman
oso96_2000
btully
jafg
tclancy
nb109
Hollow
vali29
umang_nine
dimispaceman
melihbuyuk
cindreta
voove
ringo380
gecube
Priestd09
tux-world


Optimize all tables in MySQL database


 / Published in: PHP
 

URL: http://www.totallyphp.co.uk/scripts/optimize-all-tables-in-a-mysql-database.htm

  1. <?php
  2.  
  3. dbConnect(); // Database connection
  4.  
  5. $alltables = mysql_query("SHOW TABLES");
  6.  
  7. while ($table = mysql_fetch_assoc($alltables))
  8.  
  9. {
  10. foreach ($table as $db => $tablename)
  11. {
  12. mysql_query("OPTIMIZE TABLE '".$tablename."'")
  13. }
  14. }
  15.  
  16. ?>

Report this snippet  

You need to login to post a comment.