清空數據庫表或數據


 

日常開發或服務器部署時,我們可能會遇到需要清空表或表數據的情況,下面語法執行結果即為清除語句,將結果復制到查詢中執行即可。

table_schema='數據庫名';

1、清空test庫中表數據:

select concat('truncate table ',table_schema,'.',table_name,';') as '執行sql' from information_schema.TABLES where table_schema='test';

2、刪除test庫中所有表:

select concat('drop table ',table_schema,'.',table_name,';') as '執行sql' from information_schema.TABLES where table_schema='test';

 


免責聲明!

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



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