MySQL 批量删除 表

SOSO
2021-09-17 / 0 评论 / 82 阅读 / 正在检测是否收录...

通过mysql语法组装批量删除的命令

 select concat("drop table pre_",group_concat(table_name),";")
 as statement from information_schema.tables
 where table_schema="bbs" and table_name like "pre%";

输出:

MariaDB [pbbs]> select concat("drop table pre_",group_concat(table_name),";")  as statement from information_schema.tables  where table_schema="pbbs" and table_name like "pre%"\G

*************************** 1. row ***************************
statement: drop table pw_pre_common_member_profile,pre_common_devicetoken,pre_ucenter_pm_messages_9,pre_portal_article_trash,pre_forum_statlog,pre_forum_pollvoter,pre_common_plugin,pre_common_smiley,pre_common_member_magic,pre_forum_postcomment,pre_forum_threadclass,pre_ucenter_members,pre_forum_threadlog,pre_home_share,pre_forum_attachment,pre_common_card_type,pre_common_member_validate,pre_ucenter_badwords,pre_forum_hotreply_member,pre_common_member_action_log,pre_forum_post_moderate,pre_ucenter_memberfields,pre_connect_disktask,pre_home_appcreditlog,pre_forum_faq,pre_mobile_setting,pre_common_card_log,pre_portal_topic_pic,pre_ucenter_pm_messages_2,pre_ucenter_notelist,pre_common_searchindex,pre_forum_collectionteamworker,pre_ucenter_feeds,pre_home_blog_category,pre_forum_attachment_6,pre_forum_relatedthread,pre_common_credit_log_field,pre_forum_threadmod,pre_home_pic,pre_common_credit_rule_log_field,pre_common_advertisement,pre_common_member_status,pre_forum_modwork,pre_forum_attachment_unused,pre_forum_collectionrelated,pre_home_userapp,pre_portal_topic,pre_forum_groupfield;

1 row in set (0.002 sec)

执行drop语句

drop table pw_pre_common_member_profile,pre_common_devicetoken,pre_ucenter_pm_messages_9,pre_portal_article_trash,pre_forum_statlog,pre_forum_pollvoter,pre_common_plugin,pre_common_smiley,pre_common_member_magic,pre_forum_postcomment;
0

评论 (0)

取消