Mysql批量刪除表

SELECT
    CONCAT(
        'DROP TABLE ',
        GROUP_CONCAT(table_name),
        ';'
    ) AS statement
FROM
    information_schema. TABLES
WHERE
    table_schema = 'wx-pagelog'
AND table_name LIKE 'wx_pagelog_2016090%';

---生成的sql

DROP TABLE wx_pagelog_20160901,
 wx_pagelog_20160902,
 wx_pagelog_20160903,
 wx_pagelog_20160904,
 wx_pagelog_20160905,
 wx_pagelog_20160906,
 wx_pagelog_20160907,
 wx_pagelog_20160908,
 wx_pagelog_20160909;


---注: wx-pagelog:db,wx_pagelog_2016090 要刪表的前綴。
相關文章
相關標籤/搜索