mysql - SQL: deleting tables with prefix -
How to delete my tables that have the prefix myprefix _
?
Note: The need to execute it in phpMyAdmin
You only assign it to a single MySQL can not do with the command, although you can use MySQL to create a statement for you:
In MySQL shell or through PHPMyAdmin, use the following query
< Pre> SELECT CONCAT ('DROP TABLE', GROUP_CONCAT (table_name)), ';') from the AS statement, information_schema.tables WHERE table_name 'myprefix_%';
This will generate a DROP statement that you can copy and execute to drop from the table.
EDIT: A disclaimer here - The above generated statement will drop all the tables with that prefix in all the databases if you want to limit it to the specific database, modify the query to look like this And replace database_name with your own database_name:
SELECT CONCAT ('DROP TABLE', GROUP_CONCAT (table_name), ';') info_schema.tables from the AS statement WHERE table_schema = 'database_name 'And' myprefix_% 'such as table_name;
Comments
Post a Comment