Files
2nd/10_Wiki/Topic_Programming/Topic_SQL/SQL_Select_Top.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.1 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-select-top SQL Select Top Database draft conceptual
SQL SELECT TOP
LIMIT
FETCH FIRST
SQL 상위 N개 조회
B 0.88 2026-07-04 2026-07-04
sql
database
w3schools
top
limit
fetchfirst
https://www.w3schools.com/sql/sql_top.asp

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

📝 변경 이력 (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).