MySQL Bulk Delete table

Source: Internet
Author: User

Overviewprior to debugging in the work of a cron timed task that executes every minute, each minute produces a table name with time information, and forgot to delete the scheduled task, there are nearly 3,000 new tables to be found, because the single single deletion is very slow, You now need to delete these tables with time information in bulk.
Theory&&measuretheory1 log in to the MySQL information database, find the tables table, find all the table names that meet the time requirements under the database where the table needs to be deleted2 Stitching the queried table names into the form of the drop table instruction data, for exampledrop table weekly_with_you_2014_12_28; 3 Log in to the MySQL Yc_market database and perform all the drop instructions from the previous step output

MeasureThe implementation is very simple, just need to enter the following command on the Linux terminal:[[email protected] ~]$ echo "Select Concat (' drop table ', table_name, '; ') From TABLES where Table_schema = ' yc_market ' and table_name like ' weekly_with_you_2014% '; "| mysql-uroot-p123456-h127.0.0.1 Information_schema | Sed-n ' 2, $p ' | mysql-uroot-p123456-h127.0.0.1 Yc_market

where Yc_marke is the database in which the table needs to be deletedThe sed command is used to skip the first line in all the resulting drop table directives, because the first row is invalid       

MySQL Bulk Delete table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.