--- id: sql-drop-table title: "SQL Drop Table" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL DROP TABLE Statement", "DROP TABLE", "TRUNCATE TABLE", "SQL 테이블 삭제"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["sql", "database", "w3schools", "droptable", "truncate"] raw_sources: ["https://www.w3schools.com/sql/sql_drop_table.asp"] applied_in: [] github_commit: "" --- # [[SQL Drop Table]] ## 🎯 한 줄 통찰 (One-line insight) DROP TABLE permanently removes a table and all its content, blocked if another table's foreign key still references it — while TRUNCATE TABLE clears all rows but keeps the table structure intact. [S1] ## 🧠 핵심 개념 (Core concepts) - **DROP TABLE statement** — permanently deletes an existing table and all its content. [S1] - **Syntax** — `DROP TABLE table_name;`, or safely `DROP TABLE IF EXISTS table_name;`. [S1] - **Foreign key blocking** — most databases refuse to drop a table still referenced by a foreign key constraint elsewhere; the constraint or dependent table must be removed first. [S1] - **TRUNCATE TABLE** — deletes all records in a table while keeping the table structure, columns, and constraints. [S1] ## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria) | 항목 (Option) | 장점 | 단점 | 언제 선택 | |---|---|---|---| | **DROP TABLE** | 테이블과 데이터를 완전히 제거 | 되돌릴 수 없고 구조도 사라짐, FK 참조 시 실패 | 테이블 자체가 더 이상 필요 없을 때 | | **TRUNCATE TABLE** | 구조·제약조건 유지하며 데이터만 빠르게 비움 | 개별 행 조건 삭제는 불가(전체 삭제만) | 구조는 재사용하되 데이터만 초기화할 때 | ## 📖 세부 내용 (Details) - Safe drop with existence check: `DROP TABLE IF EXISTS Shippers;`. [S1] - Truncate (empty but keep structure): `TRUNCATE TABLE table_name;`. [S1] - FK constraint blocking: dropping a table referenced by another table's FOREIGN KEY requires removing the constraint or the dependent table first. [S1] ## ⚖️ 모순 및 업데이트 (Contradictions & updates) 소스에서 모순되는 정보는 발견되지 않음. ## 🛠️ 적용 사례 (Applied in summary) 현재 발견된 실제 적용 사례가 없습니다 — SQL Delete 챕터에서 DROP TABLE이 이미 "행 삭제(DELETE)와 다르다"는 맥락으로 먼저 언급되었고, 여기서 IF EXISTS/FK 차단/TRUNCATE로 확장된다. [S1] ## 💻 코드 패턴 (Code patterns) Safe drop and truncate (SQL): ```sql DROP TABLE IF EXISTS Shippers; TRUNCATE TABLE table_name; ``` ## ✅ 검증 상태 및 신뢰도 - **상태:** draft - **검증 단계:** conceptual - **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body) - **신뢰 점수:** 0.90 - **중복 검사 결과:** 신규 생성 (New discovery) ## 🔗 지식 그래프 (Knowledge Graph) - **상위/루트:** [[SQL Tutorial]] - **관련 개념:** [[SQL Delete]], [[SQL Foreign Key]], [[SQL Create Table]] - **참조 맥락:** 테이블 자체를 제거하거나 데이터만 비워야 할 때 사용 — FOREIGN KEY 참조가 걸려있는지 먼저 확인해야 한다. ## 📚 출처 (Sources) - [S1] W3Schools — SQL DROP TABLE Statement — https://www.w3schools.com/sql/sql_drop_table.asp ## 📝 변경 이력 (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL DROP TABLE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).