首页 > 数据库 >MySql怎么批量删除多个表

MySql怎么批量删除多个表

时间:2023-04-01 16:55:05浏览次数:34  
标签:批量 删除 bonus drop flow agent game MySql table

项目场景:

使用Navicat工具直接在界面中删除,只能单张表删除,不能多选

解决方案:

我们可以通过MySQL的语句来批量删除多个表,其中you_database替换成你要查询的数据库名字 delete_table改成你要删除匹配的数据表。

1.生成删除某个数据库下所有的表SQL

-- 查询构建批量删除表语句(根据数据库名称)
select concat('drop table ', TABLE_NAME, ';') from information_schema.TABLES
where TABLE_SCHEMA = 'you_database';

2.生成删除某个数据库下指定的表名SQL

-- 查询构建批量删除表语句(根据数据库中的表名称模糊查询)
select concat('drop table ', TABLE_NAME, ';') from information_schema.TABLES
where TABLE_SCHEMA = 'you_database' and TABLE_NAME like 'delete_table_%';

3.复制查出来的删除sql语句,并批量执行。

select concat('drop table ',table_name,';') from information_schema.tables where table_schema = 'rummy_log' and table_name like 'agent_game_bonus_flow_202111%';
drop table agent_game_bonus_flow_20211110;
drop table agent_game_bonus_flow_20211111;
drop table agent_game_bonus_flow_20211112;
drop table agent_game_bonus_flow_20211113;
drop table agent_game_bonus_flow_20211114;
drop table agent_game_bonus_flow_20211115;
drop table agent_game_bonus_flow_20211116;
drop table agent_game_bonus_flow_20211117;
drop table agent_game_bonus_flow_20211118;
drop table agent_game_bonus_flow_20211119;
drop table agent_game_bonus_flow_20211120;
drop table agent_game_bonus_flow_20211121;
drop table agent_game_bonus_flow_20211122;
drop table agent_game_bonus_flow_20211123;
drop table agent_game_bonus_flow_20211124;
drop table agent_game_bonus_flow_20211125;
drop table agent_game_bonus_flow_20211126;
drop table agent_game_bonus_flow_20211127;
drop table agent_game_bonus_flow_20211128;
drop table agent_game_bonus_flow_20211129;
drop table agent_game_bonus_flow_20211130;

如图:

标签:批量,删除,bonus,drop,flow,agent,game,MySql,table
From: https://www.cnblogs.com/stronger-xsw/p/17278889.html

相关文章

  • Flink与mysql结合
    在流式计算中,不是有时候需要和mysql进行结合做一些处理。 1.调用其他方法进行  2.更快的处理使用guava本地缓存对msql的操作是new对象过来privatefinalstaticRuleServiceruleService=newRuleService();finalstaticCache<Long,Ma......
  • mysql二进制文件安装方式
    安装进制包如果用户既不想安装最简单却不够灵活的RPM包,又不想安装复杂费时的源码包,那么,已经编泽好的二进制包将是很好的选择具体安装步骤如下。(1用root登录操作系统,增加mysql用户和组,数据库将安装在此用户下:she1l>groupaddmysalshell>useradd-gmysqlmysal(2)解压二进制安......
  • 三天吃透MySQL面试八股文
    什么是MySQLMySQL是一个关系型数据库,它采用表的形式来存储数据。你可以理解成是Excel表格,既然是表的形式存储数据,就有表结构(行和列)。行代表每一行数据,列代表该行中的每个值。列上的值是有数据类型的,比如:整数、字符串、日期等等。数据库的三大范式第一范式1NF确保数据库表字段......
  • day11| 20.有效的括号;150.逆波兰表达式求值;1047.删除字符串中的所有相邻重复项
    20.有效的括号 题目简述:给定一个只包括'(',')','{','}','[',']' 的字符串s,判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。左括号必须以正确的顺序闭合。每个右括号都有一个对应的相同类型的左括号。 思路:1.利用一个栈实现2.构建一个字典,键......
  • 《Mysql基础》【Mysql触发器 新建触发器、修改触发器、删除触发器、举例】 编程入门
     --mysql数据库程序设计笔记:--=========第八章:触发器========================触发器:触发执行特定事件。(关联表对象,当特定事件出现时,触发激活)目的:保护表数据,(保证表数据完整性和一致性。)1、新建触发器:格式:createtrigger数据库名.触发器名称触发时刻inserton表名f......
  • 《Mysql基础》【Mysql表查询、去重、表连接、左连接 右连接、子表查询、排序、分组等
     --mysql数据库程序设计笔记:第三章:查询1、单表查询:1)、简单查询查所有列:格式:select*from表名;举例:mysql>select*fromtb_student;+----+-----------+-------------+------+------------+----------+--------+---------+-------------------+|id|studentNo|s......
  • mysql - 存储过程
    定义存储过程(storedprocedure)是一组为了完成特定功能的SQL语句集合,经编译后存储在服务器端的数据库中,利用存储过程可以加速SQL语句的执行。分类存储过程分为系统存储过程和自定义存储过程。1)系统存储过程在master数据库中,但是在其他的数据库中可以直接调用,并且在调用时不必在存......
  • 《Mysql基础》【Mysql表的基本操作 新建表、修改表、删除表、外键约束、主键约束、完
     --mysql数据库程序设计笔记:表基本操作:1、新建表:格式如:1)、建表加主键:createtable表名(idintNOTNULLauto_incrementcomment'自增主键id',列名类型(范围)comment'列备注',...primarykey(id))engine=InnoDB;2)、建表加候选键副键约束createtable表名......
  • 《Mysql基础》【Mysql删除数据库、新建数据库、修改数据库】 编程入门 学习分享 【公
     --mysql数据库程序设计笔记:数据定义:1、创建数据库:如:createdatabasedb_pro_1defaultcharsetgb2312collategb2312_chinese_ci;QueryOK,1rowaffected(0.00sec)或:createdatabasedb_pro_2defaultcharactersetgb2312defaultcollategb2312_chinese_ci;......
  • 如何简单快捷批量获取店铺的所有商品?
    相信有很多做电商平台的卖家也有在做其他平台的分销,就是把A平台店铺的东西铺货到B平台卖,那么第一步就需要先把A平台店铺的商品先提取出来,再在B平台上架商品,相信很多小伙伴马上想到的就是把A平台的一个店铺所有的链接都提取出来,一个一个去复制,要是店铺的商品数量少这个办......