· 8 years ago · Apr 10, 2018, 06:58 PM
1delimiter $$
2
3DROP PROCEDURE IF exist drop_tables();
4
5create procedure drop_tables()
6begin
7 SELECT
8 @drop_sql:=concat('DROP TABLE IF EXISTS ', group_concat(table_name))
9 drop_statement
10 FROM information_schema.tables
11 WHERE table_schema=database();
12 IF (@drop_sql IS NOT NULL) THEN
13 PREPARE stmt from @drop_sql;
14 EXECUTE stmt;
15 DROP PREPARE stmt;
16 END IF;
17end$$
18delimiter ;