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,84 @@
|
||||
---
|
||||
id: sql-select-top
|
||||
title: "SQL Select Top"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL SELECT TOP", "LIMIT", "FETCH FIRST", "SQL 상위 N개 조회"]
|
||||
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", "top", "limit", "fetchfirst"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_top.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Select Top]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Limiting the number of returned rows uses a different keyword per vendor — TOP (SQL Server/MS Access), LIMIT (MySQL), or FETCH FIRST (Oracle) — with no single standard syntax. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SELECT TOP clause** — limits the number of records returned; useful on large tables to avoid the performance cost of returning huge result sets. [S1]
|
||||
- **Vendor fragmentation** — SQL Server/MS Access use `TOP`, MySQL uses `LIMIT`, Oracle 12+ uses `FETCH FIRST n ROWS ONLY`. [S1]
|
||||
- **TOP PERCENT** — SQL Server/MS Access can limit by percentage of rows instead of a fixed count. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Always pair with ORDER BY for determinism** — without an explicit sort, "the first N rows" is not well-defined; ORDER BY makes a TOP/LIMIT/FETCH FIRST query reproducible. [S1]
|
||||
- **Row-limiting composes with WHERE** — vendor-specific limit syntax combines normally with WHERE filters. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **TOP (SQL Server/Access)** | 컬럼 목록 앞에 붙여 간단 | 다른 DB로 이식 불가 | SQL Server/MS Access 전용 쿼리 |
|
||||
| **LIMIT (MySQL)** | 쿼리 끝에 붙여 직관적 | 표준 SQL이 아님, 벤더 종속 | MySQL/PostgreSQL 계열 |
|
||||
| **FETCH FIRST (Oracle 12+)** | ANSI SQL:2008 표준에 가까움 | Oracle 12 이전 버전 미지원 | Oracle 최신 버전 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- SQL Server/MS Access: `SELECT TOP 3 * FROM Customers;`. [S1]
|
||||
- MySQL: `SELECT * FROM Customers LIMIT 3;`. [S1]
|
||||
- Oracle 12+: `SELECT * FROM Customers FETCH FIRST 3 ROWS ONLY;`. [S1]
|
||||
- Percent-based limit (SQL Server/Access): `SELECT TOP 50 PERCENT * FROM Customers;`. [S1]
|
||||
- Combined with WHERE and ORDER BY (SQL Server/Access): `SELECT TOP 3 * FROM Customers ORDER BY CustomerName DESC;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **표준 부재가 핵심 메시지**: "상위 N개 행" 요청 자체에 대한 SQL 표준 문법이 존재하지 않으며, 세 개 주요 벤더가 서로 다른 키워드를 사용한다는 점이 소스의 명시적 경고. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대용량 테이블에서 성능을 위해 결과 행 수를 제한하는 것은 실무에서 매우 흔한 요구사항이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Same "top 3" query per vendor (SQL):
|
||||
```sql
|
||||
-- SQL Server / MS Access
|
||||
SELECT TOP 3 * FROM Customers;
|
||||
-- MySQL
|
||||
SELECT * FROM Customers LIMIT 3;
|
||||
-- Oracle 12+
|
||||
SELECT * FROM Customers FETCH FIRST 3 ROWS ONLY;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Order By]], [[SQL Where]]
|
||||
- **참조 맥락:** 대용량 테이블에서 결과 행 수를 제한해야 할 때 참조 — 사용 중인 DB 벤더에 맞는 문법을 먼저 확인해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL SELECT TOP, LIMIT and FETCH FIRST — https://www.w3schools.com/sql/sql_top.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL SELECT TOP, LIMIT and FETCH FIRST" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user