ZKX
首页
分类
PHP
MySQL
登录/注册
sql 语句删除相同前缀的表
2019-11-05
33
0
如果你想一条一条的删除,可以使用该sql语句执行 Select CONCAT( 'drop table ', table_name, ';' ) FROM information_schema.tables Where table_name LIKE 'ims_xb_lg_%'; 执行结果 ```shell mysql> Select CONCAT( 'drop table ', table_name, ';' ) FROM information_schema.tables Where table_name LIKE 'ZipSpeed%' -> ; +------------------------------------------+ | CONCAT( 'drop table ', table_name, ';' ) | +------------------------------------------+ | drop table ZipSpeedapril2016; | | drop table ZipSpeedfebruary2016; | | drop table ZipSpeedjanuary2016; | | drop table ZipSpeedmarch2016; | +------------------------------------------+ ``` 然后复制出来一条一条地执行就可以了。 如果想一下子全部删除,那么使用如下构造语句:`reference` ```sql SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) AS statement FROM information_schema.tables WHERE table_schema = 'database_name' AND table_name LIKE 'ZipSpeed%'; ``` 把执行结果复制出来,执行 ```sql drop table ZipSpeedapril2016,ZipSpeedfebruary2016,ZipSpeedjanuary2016,ZipSpeedmarch2016; ```
标签:
mysql
评论
回复
测试人物
:
取消回复
评论正在提交中...请稍后
评论提交成功...
提交失败
评论
接口请求错误
加载更多
网站信息
联系博主
日志总数:82 篇
网站运行天数:448 天
微信:未设置
QQ:未设置
热门文章
layui 的 checkbox 联动,监听事件不准确
2019-11-05
293
4
PHP 控制 QPS (Query Per Second) 的写法
2019-11-05
237
0
phpstudy 升级 MySQL版本到MySQL5.7
2020-04-01
156
0
laravel php artisan migrate 指定迁移文件
2019-12-12
121
0
laravel 整合 workerman 做聊天室
2019-12-12
93
0
微擎数据库表结构,供参考!
2019-11-05
91
0
在使用laravel+layui时,模板语法冲突
2019-11-05
89
0
PHP 用正则分章节
2019-12-05
85
0
git 常用命令
2019-12-11
79
0
Navicat 远程连接 mysql报can't connect to mysql server on 10060
2019-11-05
78
0
在阿里云服务器上部署git
2019-11-05
78
0
curl 请求
2019-11-05
78
0