작업을 하다보면 테이블 전체를 일괄로 삭제해야할때가 있는데요.
물론 테이블이 많지 않으면 하나하나 Drop 을 해주면 되지만 그렇지 않은경우가 종종있습니다.
이럴때 사용하면 좋은 팁입니다.
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = 'DB명'; -- specify DB name here.
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
위에 DB명이라는 부분에 삭제할 데이터베이스이름을 넣고 쿼리를 실행하면됩니다.
그대로 복사해서 실행하면 아래처럼 실행되니 부분부분 궁금하신분은 참고하세요.
mysql> SET @tables = NULL;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
-> FROM information_schema.tables
-> WHERE table_schema = 'DB명'; -- specify DB name here.
Query OK, 1 row affected (0.01 sec)
mysql>
mysql> SET @tables = CONCAT('DROP TABLE ', @tables);
Query OK, 0 rows affected (0.00 sec)
mysql> PREPARE stmt FROM @tables;
Query OK, 0 rows affected (0.00 sec)
Statement prepared
mysql> EXECUTE stmt;
Query OK, 0 rows affected (0.01 sec)
mysql> DEALLOCATE PREPARE stmt;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
Empty set (0.00 sec)
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7630 | 10년 전 | 647 | ||
| 7629 |
|
10년 전 | 2376 | |
| 7628 | 10년 전 | 784 | ||
| 7627 |
|
10년 전 | 1017 | |
| 7626 |
|
10년 전 | 1782 | |
| 7625 | 10년 전 | 689 | ||
| 7624 | 10년 전 | 706 | ||
| 7623 |
|
10년 전 | 3071 | |
| 7622 | 10년 전 | 718 | ||
| 7621 |
leeleeleelee
|
10년 전 | 580 | |
| 7620 | 10년 전 | 536 | ||
| 7619 | 10년 전 | 477 | ||
| 7618 | 10년 전 | 1009 | ||
| 7617 | 10년 전 | 720 | ||
| 7616 | 10년 전 | 629 | ||
| 7615 | 10년 전 | 725 | ||
| 7614 | 10년 전 | 1250 | ||
| 7613 |
|
10년 전 | 2079 | |
| 7612 | 10년 전 | 1133 | ||
| 7611 | 10년 전 | 1401 | ||
| 7610 |
|
10년 전 | 1897 | |
| 7609 |
|
10년 전 | 1326 | |
| 7608 |
mwdkim
|
10년 전 | 1121 | |
| 7607 |
|
10년 전 | 1046 | |
| 7606 |
mwdkim
|
10년 전 | 3918 | |
| 7605 | 10년 전 | 685 | ||
| 7604 | 10년 전 | 1021 | ||
| 7603 | 10년 전 | 1645 | ||
| 7602 |
|
10년 전 | 1063 | |
| 7601 |
AniNest
|
10년 전 | 2781 | |
| 7600 |
port443
|
10년 전 | 1018 | |
| 7599 | 10년 전 | 939 | ||
| 7598 | 10년 전 | 1010 | ||
| 7597 | 10년 전 | 4566 | ||
| 7596 |
SeungYeon
|
10년 전 | 884 | |
| 7595 |
untitled
|
10년 전 | 2412 | |
| 7594 |
프로그래머7
|
10년 전 | 1718 | |
| 7593 |
untitled
|
10년 전 | 2357 | |
| 7592 |
untitled
|
10년 전 | 1929 | |
| 7591 |
untitled
|
10년 전 | 2673 | |
| 7590 |
아리마2001
|
10년 전 | 848 | |
| 7589 | 10년 전 | 1101 | ||
| 7588 |
|
10년 전 | 2910 | |
| 7587 | 10년 전 | 1300 | ||
| 7586 | 10년 전 | 663 | ||
| 7585 | 10년 전 | 1685 | ||
| 7584 | 10년 전 | 1404 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1157 | |
| 7582 |
|
10년 전 | 1100 | |
| 7581 | 10년 전 | 1317 | ||
| 7580 | 10년 전 | 979 | ||
| 7579 |
|
10년 전 | 602 | |
| 7578 | 10년 전 | 1425 | ||
| 7577 |
|
10년 전 | 1867 | |
| 7576 | 10년 전 | 1381 | ||
| 7575 |
멋진남자임
|
10년 전 | 1458 | |
| 7574 | 10년 전 | 2113 | ||
| 7573 | 10년 전 | 3244 | ||
| 7572 | 10년 전 | 756 | ||
| 7571 |
|
10년 전 | 778 | |
| 7570 |
|
10년 전 | 1303 | |
| 7569 | 10년 전 | 1544 | ||
| 7568 |
this1mg
|
10년 전 | 1045 | |
| 7567 |
|
10년 전 | 754 | |
| 7566 | 10년 전 | 914 | ||
| 7565 |
Angel하늘
|
10년 전 | 987 | |
| 7564 |
seoldi
|
10년 전 | 1226 | |
| 7563 |
|
10년 전 | 1363 | |
| 7562 |
멋진남자임
|
10년 전 | 2075 | |
| 7561 | 10년 전 | 703 | ||
| 7560 |
leeleeleelee
|
10년 전 | 893 | |
| 7559 | 10년 전 | 5034 | ||
| 7558 |
RinaP
|
10년 전 | 771 | |
| 7557 |
|
10년 전 | 1233 | |
| 7556 | 10년 전 | 1186 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1654 | |
| 7554 | 10년 전 | 1088 | ||
| 7553 |
senseme
|
10년 전 | 1333 | |
| 7552 |
ehdltdoit
|
10년 전 | 1430 | |
| 7551 |
|
10년 전 | 1814 | |
| 7550 |
leeleeleelee
|
10년 전 | 1582 | |
| 7549 | 10년 전 | 2416 | ||
| 7548 | 10년 전 | 1835 | ||
| 7547 |
멋진남자임
|
10년 전 | 1956 | |
| 7546 | 10년 전 | 998 | ||
| 7545 |
ILMare1003
|
10년 전 | 1275 | |
| 7544 |
|
10년 전 | 1242 | |
| 7543 | 10년 전 | 879 | ||
| 7542 | 10년 전 | 652 | ||
| 7541 |
울라라라우
|
10년 전 | 859 | |
| 7540 | 10년 전 | 1595 | ||
| 7539 | 10년 전 | 924 | ||
| 7538 |
|
10년 전 | 1827 | |
| 7537 | 10년 전 | 3606 | ||
| 7536 |
Gaumi
|
10년 전 | 1404 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1260 | |
| 7534 |
senseme
|
10년 전 | 1201 | |
| 7533 | 10년 전 | 1188 | ||
| 7532 | 10년 전 | 852 | ||
| 7531 | 10년 전 | 2044 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기