3/19/2019

SQL Query for All Delete(Drop) TABLE

wordpress 취약점 확인한다고 버전별로 설치/테스트/삭제 하다보니 DB 내 테이블 삭제가 매우 귀찮았습니다… 메모 차 작성해둡니다.

Db 내 모든 테이블 삭제 Query

우선 삭제할 테이블들이 속한 db명을 아래 WHERE 구절에 넣어줍시다.

[ all_delete_table.sql ]
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
  FROM information_schema.tables
  WHERE table_schema = 'DB이름';


SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
[ command line ]
$ mysql db_name < all_delete_table.sql > output



HAHWUL

Security engineer, Gopher and H4cker!

Share: | Coffee Me:

0 개의 댓글:

Post a Comment