--- id: sql-create-index title: "SQL Create Index" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL CREATE INDEX Statement", "CREATE INDEX", "CREATE UNIQUE INDEX"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["sql", "database", "w3schools", "index"] raw_sources: ["https://www.w3schools.com/sql/sql_create_index.asp"] applied_in: [] github_commit: "" --- # [[SQL Create Index]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Indexes speed up data retrieval on frequently-searched columns, but slow down writes since the index itself must be updated β€” a classic read/write trade-off, not a free performance win. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **CREATE INDEX statement** β€” creates indexes on table columns to speed up data retrieval; invisible to users, purely a performance aid. [S1] - **Write cost trade-off** β€” updating indexed tables is more time-consuming, since indexes must also be updated β€” so index only columns that are frequently searched. [S1] - **Non-unique vs. unique** β€” `CREATE INDEX` allows duplicate values; `CREATE UNIQUE INDEX` does not. [S1] - **Multi-column index** β€” listing multiple columns creates a composite index. [S1] - **DROP INDEX** β€” vendor-specific syntax to remove an index. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **DROP INDEX 문법이 4κ°€μ§€ 벀더 λͺ¨λ‘ 닀름**: SQL Server(`DROP INDEX table.index`), MySQL(`ALTER TABLE ... DROP INDEX`), MS Access(`DROP INDEX index ON table`), DB2/Oracle(`DROP INDEX index`). [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Non-unique index: `CREATE INDEX idx_lastname ON Persons (LastName);`. [S1] - Composite index: `CREATE INDEX idx_lname_fname ON Persons (LastName, FirstName);`. [S1] - Unique index syntax: `CREATE UNIQUE INDEX index_name ON table_name (column1, column2, ...);`. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 자주 κ²€μƒ‰λ˜λŠ” 컬럼(예: LastName)μ—λ§Œ μ„ νƒμ μœΌλ‘œ μ μš©ν•΄μ•Ό μ“°κΈ° μ„±λŠ₯ μ €ν•˜λ₯Ό μ΅œμ†Œν™”ν•  수 μžˆλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Single and composite index (SQL): ```sql CREATE INDEX idx_lastname ON Persons (LastName); CREATE INDEX idx_lname_fname ON Persons (LastName, FirstName); ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[SQL Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[SQL Constraints]], [[SQL Unique]], [[SQL Where]] - **μ°Έμ‘° λ§₯락:** 자주 κ²€μƒ‰λ˜λŠ” 컬럼의 쑰회 μ„±λŠ₯을 높일 λ•Œ μ‚¬μš© β€” μ“°κΈ° μ„±λŠ₯ μ €ν•˜μ™€ νŠΈλ ˆμ΄λ“œμ˜€ν”„μž„μ— 유의. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” SQL CREATE INDEX Statement β€” https://www.w3schools.com/sql/sql_create_index.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL CREATE INDEX Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).