Files
2nd/10_Wiki/Dev/Topic_SQL/SQL_Auto_Increment.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

4.5 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-auto-increment SQL Auto Increment Database draft conceptual
SQL AUTO INCREMENT Field
AUTO_INCREMENT
IDENTITY
AUTOINCREMENT
SEQUENCE
B 0.87 2026-07-04 2026-07-04
sql
database
w3schools
autoincrement
primarykey
https://www.w3schools.com/sql/sql_autoincrement.asp

SQL Auto Increment

🎯 한 줄 통찰 (One-line insight)

Every vendor auto-generates unique primary key numbers, but under a different keyword and mechanism — MySQL's AUTO_INCREMENT, SQL Server's IDENTITY, Access's AUTOINCREMENT, and Oracle's standalone SEQUENCE object requiring an explicit nextval() call. [S1]

🧠 핵심 개념 (Core concepts)

  • Auto-increment field — a numeric column that automatically generates a unique number when a new record is inserted; typically the PRIMARY KEY. [S1]
  • MySQLAUTO_INCREMENT keyword; default start 1, increments by 1; restart value via ALTER TABLE ... AUTO_INCREMENT = 100;. [S1]
  • SQL ServerIDENTITY(seed, increment), e.g. IDENTITY(1,1). [S1]
  • MS AccessAUTOINCREMENT keyword, optionally AUTOINCREMENT(seed, increment). [S1]
  • Oracle — no inline keyword; requires a standalone SEQUENCE object and explicit sequence.nextval on insert. [S1]

🧩 추출된 패턴 (Extracted patterns)

  • Insert without specifying the key — in MySQL/SQL Server/Access, an INSERT simply omits the auto-increment column and the value is generated automatically. [S1]
  • Oracle is the odd one out — Oracle requires you to explicitly reference seq_person.nextval in the INSERT statement itself, rather than the column being silently populated. [S1]

⚖️ 비교 및 선택 기준 (Comparison & decision criteria)

항목 (Option) 장점 단점 언제 선택
MySQL AUTO_INCREMENT / SQL Server IDENTITY / Access AUTOINCREMENT 컬럼 정의만으로 자동 생성, INSERT가 간단 벤더 종속 문법 해당 벤더 사용 시 기본 선택
Oracle SEQUENCE 여러 테이블이 공유 가능, 세밀한 제어(cache, start, increment) INSERT마다 .nextval 명시 필요, 별도 객체 관리 Oracle 사용 시 유일한 방법

📖 세부 내용 (Details)

  • MySQL: CREATE TABLE Persons (Personid int AUTO_INCREMENT PRIMARY KEY, ...);. [S1]
  • SQL Server: CREATE TABLE Persons (Personid int IDENTITY(1,1) PRIMARY KEY, ...);. [S1]
  • Oracle: CREATE SEQUENCE seq_person MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10; then INSERT INTO Persons (Personid, FirstName, LastName) VALUES (seq_person.nextval, 'Lars', 'Monsen');. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • 벤더 4개 모두 문법이 다름: 동일한 "자동 증가" 요구가 AUTO_INCREMENT/IDENTITY/AUTOINCREMENT/SEQUENCE로 완전히 다르게 구현됨. [S1]

🛠️ 적용 사례 (Applied in summary)

현재 발견된 실제 적용 사례가 없습니다 — PRIMARY KEY 컬럼에 값을 수동 지정하지 않고 자동 생성하고 싶을 때 표준적으로 쓰이는 패턴이다. [S1]

💻 코드 패턴 (Code patterns)

MySQL and Oracle equivalents (SQL):

-- MySQL
CREATE TABLE Persons (
    Personid int AUTO_INCREMENT PRIMARY KEY,
    LastName varchar(255) NOT NULL
);
-- Oracle
CREATE SEQUENCE seq_person MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10;
INSERT INTO Persons (Personid, FirstName, LastName)
VALUES (seq_person.nextval, 'Lars', 'Monsen');

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.87
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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