MySQL:如何使用单个查询删除多个表? [英] MySQL: how to drop multiple tables using single query?

查看:64
本文介绍了MySQL:如何使用单个查询删除多个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想轻松地删除多个表,而无需在drop查询中实际列出表名,并且要删除的表的前缀为'wp _'

I want to drop multiple tables with ease without actually listing the table names in the drop query and the tables to be deleted have prefix say 'wp_'

推荐答案

只需共享一种解决方案:

Just sharing one of the solutions:

mysql> SELECT CONCAT( "DROP TABLE",
GROUP_CONCAT(TABLE_NAME) )AS stmt

mysql> SELECT CONCAT( "DROP TABLE ",
GROUP_CONCAT(TABLE_NAME) ) AS stmt

FROM information_schema.TABLES

FROM information_schema.TABLES

WHERE TABLE_SCHEMA ="your_db_name"和TABLE_NAME就像"ur 条件"放入文件'/tmp/a.txt';

WHERE TABLE_SCHEMA = "your_db_name" AND TABLE_NAME LIKE "ur condition" into outfile '/tmp/a.txt';

mysql>源/tmp/a.txt;

mysql> source /tmp/a.txt;

这篇关于MySQL:如何使用单个查询删除多个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆