Last active
March 18, 2016 00:00
-
-
Save antyblin/8aa7532e6ed3ede8670a to your computer and use it in GitHub Desktop.
MySQL Drop all views for the table
This file contains hidden or 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
/* DROP ALL VIEWS */ | |
/* Taken from http://stackoverflow.com/a/22876345 */ | |
SET @views = NULL; | |
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @views | |
FROM information_schema.views | |
WHERE table_schema = @database_name; -- Your DB name here | |
SET @views = IFNULL(CONCAT('DROP VIEW ', @views), 'SELECT "No Views"'); | |
PREPARE stmt FROM @views; | |
EXECUTE stmt; | |
DEALLOCATE PREPARE stmt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment