docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: sql-null-functions
|
||||
title: "SQL Null Functions"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["COALESCE", "IFNULL", "ISNULL", "NVL", "SQL NULL 처리 함수"]
|
||||
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", "null", "coalesce"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_isnull.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Null Functions]]
|
||||
|
||||
# 참고: 원문 제목은 "SQL NULL Functions"이며, w3schools 사이드바에는 "SQL Null Functions"로 표기됨
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Every major SQL dialect has its own NULL-substitution function — COALESCE() is the portable standard, while IFNULL/ISNULL/NVL are vendor-specific equivalents — and a single NULL in an arithmetic expression silently NULLs the whole result unless substituted. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **The NULL-propagation problem** — an arithmetic expression involving a NULL value (e.g. `Price * (InStock + InOrder)` where `InOrder` is NULL) evaluates to NULL for that row. [S1]
|
||||
- **COALESCE()** — the preferred, portable standard; returns the first non-NULL value in a list; works in MySQL, SQL Server, and Oracle (not MS Access). [S1]
|
||||
- **IFNULL(expr, alt)** — MySQL-specific NULL substitution. [S1]
|
||||
- **ISNULL(expr, alt)** — SQL Server-specific NULL substitution. [S1]
|
||||
- **NVL(expr, alt)** — Oracle-specific NULL substitution. [S1]
|
||||
- **IsNull(expr) / IIf(expr, truepart, falsepart)** — MS Access's NULL-test-and-branch pair, used together to emulate substitution. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **One concept, five names** — "replace NULL with a default value" is implemented as five different vendor-specific functions, with COALESCE() the only one portable across MySQL/SQL Server/Oracle. [S1]
|
||||
- **MS Access needs two functions** — unlike the other vendors' single substitution function, MS Access requires composing `IsNull()` (test) with `IIf()` (branch) to achieve the same effect. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **COALESCE()** | MySQL/SQL Server/Oracle에서 이식 가능, 표준에 가까움 | MS Access 미지원 | 여러 DB를 오갈 가능성이 있는 코드 |
|
||||
| **IFNULL/ISNULL/NVL** | 해당 벤더에서 짧고 관용적 | 다른 DB로 이식 불가 | 특정 벤더 전용 코드베이스 |
|
||||
| **MS Access IsNull()+IIf()** | Access 네이티브 방식 | 두 함수 조합이 필요해 장황함 | MS Access 전용 쿼리 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- NULL propagation problem: `SELECT ProductName, Price * (InStock + InOrder) FROM Products;` — returns NULL for any row where `InOrder` is NULL. [S1]
|
||||
- COALESCE fix: `SELECT ProductName, Price * (InStock + COALESCE(InOrder, 0)) FROM Products;`. [S1]
|
||||
- MySQL: `SELECT ProductName, Price * (InStock + IFNULL(InOrder, 0)) FROM Products;`. [S1]
|
||||
- SQL Server: `SELECT ProductName, Price * (InStock + ISNULL(InOrder, 0)) FROM Products;`. [S1]
|
||||
- Oracle: `SELECT ProductName, Price * (InStock + NVL(InOrder, 0)) FROM Products;`. [S1]
|
||||
- MS Access: `SELECT ProductName, Price * (InStock + IIf(IsNull(InOrder), 0, InOrder)) FROM Products;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **벤더별 함수명 불일치가 핵심 메시지**: 동일한 의도가 COALESCE/IFNULL/ISNULL/NVL/IsNull+IIf로 벤더마다 다르게 구현됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 재고 계산처럼 산술식에 NULL이 섞일 수 있는 모든 계산 쿼리에서 재사용되는 방어적 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Portable NULL substitution (SQL, COALESCE):
|
||||
```sql
|
||||
SELECT ProductName, Price * (InStock + COALESCE(InOrder, 0))
|
||||
FROM Products;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Null Values]], [[SQL Case]]
|
||||
- **참조 맥락:** 산술식·집계에 NULL이 섞여 결과가 오염되는 것을 막을 때 사용 — 이식성이 필요하면 COALESCE()를 우선 고려.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL NULL Functions — https://www.w3schools.com/sql/sql_isnull.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL NULL Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user