欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySql批量刪除多個表的方法

 更新時間:2023年06月09日 10:15:37   作者:可樂漢堡cola  
本文主要介紹了MySql批量刪除多個表的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

項目場景:

使用Navicat工具直接在界面中刪除,只能單張表刪除,不能多選。

解決方案:

我們可以通過MySQL的語句來批量刪除多個表,其中test替換成你要查詢的數(shù)據(jù)庫名字。

1.生成刪除某個數(shù)據(jù)庫下所有的表SQL

-- 查詢構(gòu)建批量刪除表語句(根據(jù)數(shù)據(jù)庫名稱)
select concat('drop table ', TABLE_NAME, ';') from information_schema.TABLES
where TABLE_SCHEMA = 'test';

2.生成刪除某個數(shù)據(jù)庫下指定的表名SQL

-- 查詢構(gòu)建批量刪除表語句(根據(jù)數(shù)據(jù)庫中的表名稱模糊查詢)
select concat('drop table ', TABLE_NAME, ';') from information_schema.TABLES
where TABLE_SCHEMA = 'test' and TABLE_NAME like 'sys_%';

復(fù)制查出來的刪除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;

到此這篇關(guān)于MySql批量刪除多個表的方法的文章就介紹到這了,更多相關(guān)MySql批量刪除表內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論