MySql批量刪除多個表的方法
項目場景:
使用Navicat工具直接在界面中刪除,只能單張表刪除,不能多選。
解決方案:
我們可以通過MySQL的語句來批量刪除多個表,其中test替換成你要查詢的數(shù)據(jù)庫名字。
1.生成刪除某個數(shù)據(jù)庫下所有的表SQL
-- 查詢構建批量刪除表語句(根據(jù)數(shù)據(jù)庫名稱)
select concat('drop table ', TABLE_NAME, ';') from information_schema.TABLES
where TABLE_SCHEMA = 'test';2.生成刪除某個數(shù)據(jù)庫下指定的表名SQL
-- 查詢構建批量刪除表語句(根據(jù)數(shù)據(jù)庫中的表名稱模糊查詢)
select concat('drop table ', TABLE_NAME, ';') from information_schema.TABLES
where TABLE_SCHEMA = 'test' and TABLE_NAME like 'sys_%';復制查出來的刪除sql語句,并批量執(zhí)行。
drop table sys_dept; drop table sys_dict; drop table sys_log; drop table sys_log_2022; drop table sys_menu; drop table sys_notice; drop table sys_role; drop table sys_role_menu; drop table sys_user; drop table sys_user_dept; drop table sys_user_role; drop table sys_user_token;

到此這篇關于MySql批量刪除多個表的方法的文章就介紹到這了,更多相關MySql批量刪除表內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
修改MySQL8.0 默認的數(shù)據(jù)目錄(快捷操作無配置)
這篇文章主要介紹了修改MySQL8.0 默認的數(shù)據(jù)目錄(快捷操作無配置),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-11-11
PHP使用mysqli擴展連接MySQL數(shù)據(jù)庫
這篇文章主要介紹了PHP使用mysqli擴展連接MySQL數(shù)據(jù)庫,需要的朋友可以參考下2014-08-08
如何用workbench導出mysql數(shù)據(jù)庫關系圖
用workbench導出mysql數(shù)據(jù)庫關系圖的解決方法,需要的朋友請往下閱讀2013-03-03
解決ERROR?1129?(HY000):?Host?‘xxx‘?is?blocked?because?
這篇文章主要介紹了解決ERROR?1129?(HY000):?Host?‘xxx‘?is?blocked?because?of?many問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-04-04

