Truncate all tables in a MySQL database in one command?(在一个命令中截断 MySQL 数据库中的所有表?)
问题描述
Is there a query (command) to truncate all the tables in a database in one operation? I want to know if I can do this with one single query.
Drop (i.e. remove tables)
mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "drop table $table" DATABASE_NAME; done
Truncate (i.e. empty tables)
mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "truncate table $table" DATABASE_NAME; done
这篇关于在一个命令中截断 MySQL 数据库中的所有表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!