方法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'
SELECT concat('DROP TABLE IF EXISTS ', table_name, ';')
FROM information_schema.tables
WHERE table_schema = '
mydb'; mydb換成你想刪除的數據庫的名字 這樣能夠生成一個批量處理的sql語句,你須要再運行一次這個結果集 就能夠刪除全部的表而不刪除數據庫了