--- id: sql-aliases title: "SQL Aliases" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL Alias", "AS keyword", "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", "alias", "join"] raw_sources: ["https://www.w3schools.com/sql/sql_alias.asp"] applied_in: [] github_commit: "" --- # [[SQL Aliases]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) An alias, created with AS, gives a column or table a temporary, more readable name that exists only for the duration of the query β€” and becomes essential once tables are joined. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Alias** β€” created with the `AS` keyword; makes a column name more readable; only exists for the duration of that query. [S1] - **Column alias syntax** β€” `SELECT column_name AS alias_name FROM table_name;`. [S1] - **Table alias syntax** β€” `SELECT column_name(s) FROM table_name AS alias_name;`. [S1] - **Aliases with spaces** β€” wrap in square brackets `[My Great Products]` or double quotes `"My Great Products"` (support varies by DB system). [S1] - **Concatenation alias** β€” combining multiple columns into one output column needs an alias to name the combined result. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Table alias for joins** β€” short aliases like `c` for customers and `o` for orders make multi-table JOIN queries shorter and more readable: `FROM customers AS c JOIN orders AS o ON c.customerID = o.customerID`. [S1] - **Vendor-specific concatenation syntax** β€” the same "combine 4 address columns into one" intent needs different syntax per DB: `+` (SQL Server), `CONCAT()` (MySQL), `||` (Oracle). [S1] - **When aliases matter most** β€” the source lists: multiple tables in a query, functions used in the query, long/unclear column names, and combined columns. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Basic column alias: `SELECT CustomerID AS ID, CustomerName AS Customer FROM Customers;`. [S1] - Alias with spaces (bracket form): `SELECT ProductName AS [My Great Products] FROM Products;`. [S1] - Alias with spaces (quote form): `SELECT ProductName AS "My Great Products" FROM Products;`. [S1] - Concatenated column alias (SQL Server): `SELECT CustomerName, Address + ', ' + PostalCode + ' ' + City + ', ' + Country AS Address FROM Customers;`. [S1] - Same intent in MySQL: `SELECT CustomerName, CONCAT(Address,', ',PostalCode,', ',City,', ',Country) AS Address FROM Customers;`. [S1] - Same intent in Oracle: `SELECT CustomerName, (Address || ', ' || PostalCode || ' ' || City || ', ' || Country) AS Address FROM Customers;`. [S1] - Table alias: `SELECT * FROM Customers AS Persons;` and, for joins, `FROM customers AS c JOIN orders AS o ON c.customerID = o.customerID`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **λ¬Έμžμ—΄ μ—°κ²° 문법이 DBλ§ˆλ‹€ 닀름**: λ™μΌν•œ "4개 컬럼 ν•©μΉ˜κΈ°" μš”κ΅¬κ°€ SQL Server(`+`), MySQL(`CONCAT()`), Oracle(`||`)μ—μ„œ 각각 λ‹€λ₯Έ μ—°μ‚°μžλ‘œ κ΅¬ν˜„λ¨ β€” ν‘œμ€€ SQL이 μ•„λ‹Œ 방언별 차이. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 이후 JOIN 챕터 μ „μ²΄μ—μ„œ ν…Œμ΄λΈ” 별칭(c, o λ“±)이 κ΄€μš©μ μœΌλ‘œ μž¬μ‚¬μš©λœλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Column alias (SQL): ```sql SELECT CustomerID AS ID, CustomerName AS Customer FROM Customers; ``` Table alias for a join (SQL): ```sql SELECT c.CustomerName, o.OrderID FROM customers AS c JOIN orders AS o ON c.customerID = o.customerID; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[SQL Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[SQL Select]], [[SQL Joins]], [[SQL Inner Join]] - **μ°Έμ‘° λ§₯락:** 닀쀑 ν…Œμ΄λΈ” JOIN 쿼리λ₯Ό 읽기 μ‰½κ²Œ λ§Œλ“œλŠ” ν‘œμ€€ κ΄€μš©κ΅¬ β€” 이후 λͺ¨λ“  JOIN μ±•ν„°μ˜ μ „μ œ 지식. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” SQL Aliases β€” https://www.w3schools.com/sql/sql_alias.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL Aliases" page (Astra wiki-curation, P-Reinforce v3.1 format).