Mysql Bulk Delete prefix or suffix table

Source: Internet
Author: User

Oracl has the use of drop table like, but MySQL does not, you can write scripts (do not repeat), you can also assemble SQL.


Note that my database name is test, there is a table called data, and then I prepare four tables with the same prefix, bulk Delete, prepare the data can be used this SQL

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_12% ';

On top of this SQL is to display a SQL result, the above execution of the results of the execution side.

(Just change Table_schema (this is the name of the database), with table_name (this is the name of the data table)
DROP TABLE test_1201,test_1202,test_1203;

Mysql Bulk Delete prefix or suffix table

Related Article

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.