2017. 1. 4.

Mysql :: 데이터베이스 하위 테이블 모두 삭제


--외래키무시.

SET foreign_key_checks = 0;
SET @tables = NULL;

SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables 
WHERE table_schema = '데이터베이스명'; -- specify DB name here.
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;


--외래키 다시 허용.

SET foreign_key_checks = 1;

댓글 없음:

댓글 쓰기