Last active
October 10, 2015 15:58
-
-
Save 66Ton99/3715102 to your computer and use it in GitHub Desktop.
Deletes all tables in current DB
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
delimiter $$ | |
create procedure drop_tables_like(pattern varchar(255), db varchar(255)) | |
begin | |
select @str_tables:=group_concat(table_name) | |
from information_schema.tables | |
where table_schema=db and table_name like pattern; | |
IF @str_tables IS NOT NULL THEN | |
SET @str_sql := concat('drop table ', @str_tables); | |
prepare stmt from @str_sql; | |
execute stmt; | |
drop prepare stmt; | |
END IF; | |
end$$ | |
call drop_tables_like('%%', DATABASE())$$ | |
drop procedure drop_tables_like$$ | |
delimiter ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment