Created
January 4, 2011 17:55
-
-
Save lukmdo/765112 to your computer and use it in GitHub Desktop.
various MySQL stored procedures
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 procedure IF EXISTS clear_db; | |
DELIMITER // | |
CREATE PROCEDURE clear_db () | |
BEGIN | |
SET @tName := (SELECT table_name from information_schema.tables where table_schema = DATABASE() ORDER BY table_name LIMIT 1); | |
WHILE @tName IS NOT NULL DO | |
# SELECT CONCAT("Dropping tabe: ", @tName) as msg; | |
SET @s = CONCAT("DROP TABLE ", @tName); | |
PREPARE dropIT FROM @s; | |
EXECUTE dropIT; | |
SET @tName := (SELECT table_name from information_schema.tables where table_schema = DATABASE() ORDER BY table_name LIMIT 1); | |
END WHILE; | |
DEALLOCATE PREPARE dropIT; | |
END | |
// | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment