Files
2nd/10_Wiki/Topic_Programming/Topic_SQL/SQL_Null_Functions.md
T
Antigravity Agent e9cbf23ab5 docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영.

- Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들
  (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거.
- Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/
  Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/
  Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이
  존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존).
- Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/
  JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동.
- 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리.
- Topic_Programming 최종 문서 수: 2784 → 3985.
2026-07-05 00:39:13 +09:00

4.8 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
sql-null-functions SQL Null Functions Database draft conceptual
COALESCE
IFNULL
ISNULL
NVL
SQL NULL 처리 함수
B 0.88 2026-07-04 2026-07-04
sql
database
w3schools
null
coalesce
https://www.w3schools.com/sql/sql_isnull.asp

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):

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)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "SQL NULL Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).