Created
April 26, 2018 00:02
-
-
Save bjpeterdelacruz/54a52abe09f694e426052536cd0fc0b4 to your computer and use it in GitHub Desktop.
How to generate DROP TABLE statements for tables that begin with a certain prefix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generate DROP TABLE statements for tables that begin with "ap_form_" | |
SELECT CONCAT('DROP TABLE `', TABLE_NAME, '`;') AS queries | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE TABLE_NAME LIKE 'ap_form_%' | |
-- Sample output: | |
-- DROP TABLE `ap_form_10792`; | |
-- DROP TABLE `ap_form_10792_review`; | |
-- DROP TABLE `ap_form_11763`; | |
-- DROP TABLE `ap_form_11763_review`; | |
-- DROP TABLE `ap_form_14547`; | |
-- DROP TABLE `ap_form_14547_review`; | |
-- DROP TABLE `ap_form_15515`; | |
-- DROP TABLE `ap_form_15515_review`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment