--- id: sql-update title: "SQL Update" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL UPDATE Statement", "UPDATE statement", "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", "update"] raw_sources: ["https://www.w3schools.com/sql/sql_update.asp"] applied_in: [] github_commit: "" --- # [[SQL Update]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) UPDATE modifies existing records, and omitting its WHERE clause is a critical footgun that silently rewrites every row in the table. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **UPDATE statement** β€” updates or modifies one or more existing records in a table. [S1] - **Syntax** β€” `UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;`. [S1] - **WHERE determines scope** β€” the WHERE clause specifies exactly which record(s) get updated. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Missing-WHERE footgun** β€” the source explicitly warns: omit WHERE and ALL records in the table are updated. This is called out twice (as a "Note" and as an "Update Warning!") β€” a strong signal that this is the most common and costly mistake with this statement. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Update a single record: `UPDATE Customers SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1;`. [S1] - Update multiple records matching a condition: `UPDATE Customers SET ContactName='Juan' WHERE Country='Mexico';`. [S1] - Update ALL records (WHERE omitted β€” dangerous, shown as a cautionary example): `UPDATE Customers SET ContactName='Juan';`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. WHERE μƒλž΅μ˜ μœ„ν—˜μ„±μ΄ μ†ŒμŠ€ λ‚΄μ—μ„œ 두 μ°¨λ‘€ 강쑰됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” ν”„λ‘œλ•μ…˜μ—μ„œ UPDATE μ‹€ν–‰ μ „ WHERE 쑰건을 SELECT둜 λ¨Όμ € κ²€μ¦ν•˜λŠ” μŠ΅κ΄€μ΄ μ†ŒμŠ€μ˜ κ²½κ³ μ—μ„œ μžμ—°μŠ€λŸ½κ²Œ λ„μΆœλœλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Update one record (SQL): ```sql UPDATE Customers SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1; ``` Update matching multiple records (SQL): ```sql UPDATE Customers SET ContactName='Juan' WHERE Country='Mexico'; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[SQL Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[SQL Where]], [[SQL Delete]], [[SQL Insert Into]] - **μ°Έμ‘° λ§₯락:** CRUD의 Update μΆ• β€” WHERE 절 λˆ„λ½ μœ„ν—˜μ„ 항상 ν•¨κ»˜ κΈ°μ–΅ν•΄μ•Ό ν•œλ‹€. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” SQL UPDATE Statement β€” https://www.w3schools.com/sql/sql_update.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL UPDATE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).