Mysql batch delete prefix or suffix table _ MySQL

Source: Internet
Author: User
Oracl has the usage of droptablelike, But mysql does not. you can write scripts (do not repeat them) or assemble SQL statements. Note: my database name is test and there is a table named data. then I prepare four tables with the same prefix and delete them in batches, you can use this sqlC oracl to prepare data for drop table like usage, but mysql does not. you can write a script (not to repeat it) or assemble an SQL statement.


Note: my database name is test and there is a table named data. then I prepare four tables with the same prefix and delete them in batches. This SQL statement can be used to prepare data.

Create table test_1201 SELECT * FROM 'data ';
Create table test_1202 SELECT * FROM 'data ';
Create table test_1203 SELECT * FROM 'data ';
Create table test_1205 SELECT * FROM 'data ';
Select concat ("drop table", GROUP_CONCAT (table_name), ';') AS statement FROM information_schema.tables WHERE table_schema = 'test' AND table_name LIKE 'test _ 100 ';

The preceding SQL statement displays an SQL result. you can run the preceding SQL result on one side.

(Change table_schema (this is the database name) and table_name (this is the name of the data table)
Drop table test_1201, test_1202, test_1203;

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.