且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL:如何使用单个查询删除多个表?

更新时间:2023-01-23 11:03:35

只需共享一种解决方案:

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;