MySQL对比清除不必要的表

1. 将需要包含表查询并放到临时表中:show tables;

2. 使用下面SQL生成删除不必要表的SQL:

select concat('drop table if exists `', a.table_name, '`;')
from information_schema.tables a left join tmp.a tmp
on a.table_name = tmp.name
where a.table_schema = 'cook' and tmp.name is null

3. 执行2中生成的SQL

原文地址:https://www.cnblogs.com/roostinghawk/p/13670982.html