SQL statement for bulk deletion of the specified prefix table in Mysql _mysql

Source: Internet
Author: User
Copy Code code as follows:

Select CONCAT (' drop table ', table_name, '; ')
From Information_schema.tables
Where table_name like ' dede_% ';


"Dede" for the table prefix to be deleted, executing this SQL statement generates a string of SQL statements that must be executed again to perform the delete operation



The other is to bulk modify the table name:

Copy Code code as follows:

Select CONCAT (' ALTER TABLE ', table_name, ' RENAME to ', table_name, '; ')
From Information_schema.tables
Where table_name like ' dede_% ';


This SQL statement is executed first, and the following statement is generated:

Copy Code code as follows:

ALTER TABLE de_aaa RENAME to DE_AAA;
ALTER TABLE de_bbb RENAME to DE_BBB;


In the editor, change the "RENAME to de" batch to the table prefix you want to set, and then execute this SQL statement to batch modify the table name.

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.