--- id: sql-not-null title: "SQL Not Null" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL NOT NULL Constraint", "NOT NULL constraint"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["sql", "database", "w3schools", "notnull", "constraints"] raw_sources: ["https://www.w3schools.com/sql/sql_notnull.asp"] applied_in: [] github_commit: "" --- # [[SQL Not Null]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) NOT NULL forces a column to always hold a value β€” columns are nullable by default β€” and can be added to or removed from an existing table via vendor-specific ALTER TABLE syntax. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **NOT NULL constraint** β€” enforces a column to not accept NULL values; you cannot insert/update a record without a value for that field. [S1] - **Default is nullable** β€” columns accept NULL by default unless NOT NULL is specified. [S1] - **On CREATE TABLE** β€” add `NOT NULL` after the column's data type. [S1] - **On ALTER TABLE** β€” vendor-specific: SQL Server/MS Access use `ALTER COLUMN`, MySQL uses `MODIFY COLUMN`, Oracle 10G+ uses `MODIFY`. [S1] - **Removing NOT NULL** β€” same vendor-specific ALTER syntax, but specifying `NULL` instead of `NOT NULL`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - On table creation: `CREATE TABLE Persons (ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, Age int);`. [S1] - Add NOT NULL after creation (SQL Server/Access): `ALTER TABLE Persons ALTER COLUMN Age int NOT NULL;`. [S1] - Add NOT NULL after creation (MySQL): `ALTER TABLE Persons MODIFY COLUMN Age int NOT NULL;`. [S1] - Remove NOT NULL (SQL Server/Access): `ALTER TABLE Persons ALTER COLUMN Age int NULL;`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **벀더별 ALTER 문법 차이**: SQL Server/Access(`ALTER COLUMN`) vs. MySQL(`MODIFY COLUMN`) vs. Oracle(`MODIFY`)κ°€ μ„œλ‘œ 닀름. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” PRIMARY KEY의 ꡬ성 μš”μ†Œ(UNIQUE + NOT NULL) 쀑 ν•˜λ‚˜λ‘œ μž¬μ‚¬μš©λœλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) NOT NULL on table creation (SQL): ```sql CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, Age int ); ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[SQL Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[SQL Constraints]], [[SQL Primary Key]], [[SQL Null Values]] - **μ°Έμ‘° λ§₯락:** ν•„μˆ˜ μž…λ ₯ μ»¬λŸΌμ„ κ°•μ œν•  λ•Œ μ‚¬μš© β€” PRIMARY KEY ꡬ성 μš”μ†Œ 쀑 ν•˜λ‚˜. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” SQL NOT NULL Constraint β€” https://www.w3schools.com/sql/sql_notnull.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL NOT NULL Constraint" page (Astra wiki-curation, P-Reinforce v3.1 format).