--- id: sql-syntax title: "SQL Syntax" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL Statements", "SQL keywords", "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", "syntax"] raw_sources: ["https://www.w3schools.com/sql/sql_syntax.asp"] applied_in: [] github_commit: "" --- # [[SQL Syntax]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Most database actions are performed with SQL statements built from easy-to-understand keywords, which are case-insensitive but conventionally written in upper-case and terminated with a semicolon. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **SQL statements** β€” the unit of action against a database; consist of keywords such as `SELECT`, `UPDATE`, `DELETE`, `INSERT INTO`. [S1] - **Database tables** β€” a database most often contains one or more named tables (e.g. "Customers"), each holding records (rows) with data; this tutorial uses the well-known Northwind sample database. [S1] - **Case insensitivity** β€” SQL keywords are NOT case sensitive (`select` is the same as `SELECT`); convention favors upper-case keywords. [S1] - **Semicolons** β€” some database systems require a semicolon to separate multiple SQL statements sent in the same call to the server. [S1] - **Most important SQL commands** β€” `SELECT`, `UPDATE`, `DELETE`, `INSERT INTO`, `CREATE DATABASE`, `ALTER DATABASE`, `CREATE TABLE`, `ALTER TABLE`, `DROP TABLE`, `CREATE INDEX`, `DROP INDEX`. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Upper-case keyword convention** β€” writing keywords in upper-case (even though not required) improves readability and is the convention followed throughout the tutorial. [S1] - **Statement-terminator discipline** β€” always ending statements with `;` avoids ambiguity when multiple statements are sent together, even on systems where it isn't strictly required. [S1] ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) | ν•­λͺ© (Option) | μž₯점 | 단점 | μ–Έμ œ 선택 | |---|---|---|---| | **μ„Έλ―Έμ½œλ‘  μ‚¬μš©** | μ—¬λŸ¬ SQL문을 ν•œ λ²ˆμ— 보낼 λ•Œ ꡬ뢄이 λͺ…확함 | μ„Έλ―Έμ½œλ‘ μ„ μš”κ΅¬ν•˜μ§€ μ•ŠλŠ” μ‹œμŠ€ν…œμ—μ„œλŠ” λΆˆν•„μš”ν•΄ 보일 수 있음 | 닀쀑 statement 전솑이 ν•„μš”ν•˜κ±°λ‚˜ 이식성을 κ³ λ €ν•  λ•Œ | | **μ„Έλ―Έμ½œλ‘  μƒλž΅** | 단일 statement μ‹€ν–‰ μ‹œ 더 간결함 | μ‹œμŠ€ν…œμ— 따라 였λ₯˜κ°€ λ‚  수 있음 | μ„Έλ―Έμ½œλ‘ μ„ λͺ…μ‹œμ μœΌλ‘œ μš”κ΅¬ν•˜μ§€ μ•ŠλŠ” 단일 statement ν™˜κ²½ | ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - The following statement selects all records from the "Customers" table: [S1] ```sql SELECT * FROM Customers; ``` - A sample from the Customers table has columns `CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country` with rows like `1 | Alfreds Futterkiste | Maria Anders | Obere Str. 57 | Berlin | 12209 | Germany`. [S1] - Most important SQL commands (grouped by purpose): [S1] - Data: `SELECT`, `UPDATE`, `DELETE`, `INSERT INTO` - Database: `CREATE DATABASE`, `ALTER DATABASE` - Table: `CREATE TABLE`, `ALTER TABLE`, `DROP TABLE` - Index: `CREATE INDEX`, `DROP INDEX` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. λ‹€λ§Œ "일뢀 λ°μ΄ν„°λ² μ΄μŠ€ μ‹œμŠ€ν…œλ§Œ μ„Έλ―Έμ½œλ‘ μ„ μš”κ΅¬ν•œλ‹€"λŠ” μ„œμˆ  μžμ²΄κ°€ μ‹œμŠ€ν…œλ§ˆλ‹€ λ™μž‘μ΄ λ‹€λ₯Ό 수 μžˆμŒμ„ λͺ…μ‹œν•˜κ³  μžˆλ‹€. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 이 λ¬Έμ„œμ—μ„œ μ •μ˜ν•œ λŒ€λ¬Έμž ν‚€μ›Œλ“œ/μ„Έλ―Έμ½œλ‘  μ»¨λ²€μ…˜μ€ νŠœν† λ¦¬μ–Ό 전체 μ˜ˆμ œμ—μ„œ μΌκ΄€λ˜κ²Œ μ‚¬μš©λœλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Select all records (SQL): ```sql SELECT * FROM Customers; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[SQL Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[SQL Intro]], [[SQL Select]], [[SQL Comments]] - **μ°Έμ‘° λ§₯락:** 이후 λͺ¨λ“  SQL μ˜ˆμ œκ°€ λ”°λ₯΄λŠ” ν‘œκΈ° κ΄€λ‘€(λŒ€λ¬Έμž ν‚€μ›Œλ“œ, μ„Έλ―Έμ½œλ‘ )λ₯Ό μ •μ˜ν•˜λŠ” λ¬Έμ„œ. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” SQL Syntax β€” https://www.w3schools.com/sql/sql_syntax.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL Syntax" page (Astra wiki-curation, P-Reinforce v3.1 format).