으악.... 질문자/답변자가.......ㅋ
감사합니다. 저 질문을 했던 게 전혀 기억이 안 나네요. ㅜㅜ
PS. 덕분에 아래 코드로 잘 지웠습니다.
DELIMITER ;
SET FOREIGN_KEY_CHECKS = ON;
DELIMITER //
DROP PROCEDURE IF EXISTS `DROP_TABLES`//
CREATE PROCEDURE `DROP_TABLES`(IN dbname VARCHAR(100), IN tblname_prefix VARCHAR(100))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE db VARCHAR(100);
DECLARE tbl VARCHAR(255);
DECLARE cur CURSOR FOR SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = dbname;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur;
read_loop: LOOP
FETCH cur INTO db, tbl;
IF done THEN
LEAVE read_loop;
END IF;
IF INSTR(tbl, tblname_prefix) = 1 THEN
SET @query = CONCAT('DROP TABLE ', db, '.', tbl);
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SELECT CONCAT(db, '.', tbl, ' is dropped') removed FROM DUAL;
END IF;
END LOOP;
CLOSE cur;
END//
DELIMITER ;
CALL DROP_TABLES('gnu55', 'ko_');