This is a simple PHP script to empty all tables in a MySQL database. This script first will list all tables in a database using ‘SHOW TABLES‘ statement then it will empty each table using ’TRUNCATE TABLE‘ statement.
$con = mysql_connect('dbhost','dbuser','dbpassword');
if (!$con) die("Can't connect to database!");
mysql_select_db('dbname');
$res = mysql_query('SHOW TABLES', $con);
while ($row = mysql_fetch_array($res, MYSQL_NUM))
{
$res2 = mysql_query("TRUNCATE TABLE `$row[0]`", $con);
}
About TRUNCATE Statement
For an InnoDB table before version 5.0.3, InnoDB processes TRUNCATE TABLE by deleting rows one by one. As of MySQL 5.0.3, row by row deletion is used only if there are any foreign key constraints that reference the table. If there are no foreign key constraints, InnoDB performs fast truncation by dropping the original table and creating an empty one with the same definition, which is much faster than deleting rows one by one.
Related post:
SECRETS OF YOGA…
SECRETS OF Yoga Awakening Meditation Collection 21-day Trial Now!!!…
Free and Fast Easy Health Weight Loss Diet Ideas…
How To Fast Easy Health Weight Loss and good Ideas for Diet,Let’s Go Start Losing Weight Now!…
Tnks Very Much!
secrets of yoga? natural wieght loss?? lol wtf???
[...] mango acquired diet you may be familiar. Because the important decision to purchase on-line. With all the African mango compared to you take a supplement are not removed by the FDA will make your body weight to [...]