【轉】清空mysql一個庫中的所有表的數據


方法1:重建庫和表
用mysqldump --no-data把建表SQL導出來,然后drop database再create database,執行一下導出的SQL文件;

方法2:生成清空所有表的SQL

select CONCAT('TRUNCATE TABLE ',table_name,';') from information_schema.tables where TABLE_SCHEMA = 'db1'

導出到文件
select CONCAT('TRUNCATE TABLE ',table_name,';') into outfile '/website/truncatetable.sql' from information_schema.tables where TABLE_SCHEMA = 'db1'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM