开发者

SQL statement to truncate all data from all tables in the database [duplicate]

开发者 https://www.devze.com 2023-01-05 22:31 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: Truncate all tables in a MySQL database in one command?
This question already has answers here: Closed 12 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消