SQL statement to truncate all data from all tables in the database [duplicate]
Possible Duplicate:
Truncate all tables in a MySQL database in one command?
how to delete all the data from all tables in the databas开发者_如何学Ce.
use like this,
TRUNCATE `table1`;
TRUNCATE `table2`;
TRUNCATE `table3`;
TRUNCATE `table4`;
If you have scripted creation of empty tables, it may be faster to drop and recreate the database, depending on number of tables. It is less typing for sure :-) -
You have to do it in single statements. You could create a loop, assigning the next table name to a variable and then use dynamic sql to execute the TRUNCATE
statement.
精彩评论