A column constraint that prevents NULL values from being stored, requiring every row to supply a value for that column.
Prevents NULL values in a column, requiring a defined value. The simplest and most important constraint for data quality. Combine with DEFAULT to avoid NULLs from inserts that omit the column.
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | ✓ Supported | all | Standard NOT NULL. Strict mode (STRICT_ALL_TABLES or STRICT_TRANS_TABLES) affects behavior: without strict mode, MySQL may insert empty string or 0 instead of rejecting the INSERT on a NOT NULL column — enabling strict mode is strongly recommended. |
| PostgreSQL | ✓ Supported | all | Standard NOT NULL. PG 17 adds ALTER TABLE ... ALTER COLUMN ... SET NOT NULL as a fast path that avoids a full table scan when a CHECK constraint already guarantees no NULLs. NOT NULL can also be added as a named constraint (ALTER TABLE ... ADD CONSTRAINT ... NOT NULL) in PG 17+. |
| SQL Server | ✓ Supported | all | Standard NOT NULL. Columns are nullable by default. To change nullability on an existing column the column must be redefined with ALTER TABLE ... ALTER COLUMN. If data contains NULLs, the ALTER will fail. |
| Oracle | ✓ Supported | all | Standard NOT NULL. In Oracle, an empty string ('') is treated as NULL — unlike every other engine. This means NOT NULL also blocks empty string inserts. Modifying nullability: ALTER TABLE ... MODIFY col NOT NULL or ALTER TABLE ... MODIFY col NULL. |
| SQLite | ✓ Supported | all | Standard NOT NULL. The exception: INTEGER PRIMARY KEY columns implicitly get NOT NULL (and auto-increment behavior). SQLite allows ALTER TABLE to rename columns and add columns, but NOT NULL cannot be added to an existing column without recreating the table. |
Oracle's treatment of empty string ('') as NULL is a notorious portability trap — NOT NULL in Oracle also blocks empty strings, unlike all other engines. MySQL without strict mode may silently coerce a NOT NULL violation to a default value instead of rejecting the INSERT, which is arguably worse behavior than an error.
Standard NOT NULL. Strict mode (STRICT_ALL_TABLES or STRICT_TRANS_TABLES) affects behavior: without strict mode, MySQL may insert empty string or 0 instead of rejecting the INSERT on a NOT NULL column — enabling strict mode is strongly recommended.
Standard NOT NULL. PG 17 adds ALTER TABLE ... ALTER COLUMN ... SET NOT NULL as a fast path that avoids a full table scan when a CHECK constraint already guarantees no NULLs. NOT NULL can also be added as a named constraint (ALTER TABLE ... ADD CONSTRAINT ... NOT NULL) in PG 17+.
Standard NOT NULL. Columns are nullable by default. To change nullability on an existing column the column must be redefined with ALTER TABLE ... ALTER COLUMN. If data contains NULLs, the ALTER will fail.
Standard NOT NULL. In Oracle, an empty string ('') is treated as NULL — unlike every other engine. This means NOT NULL also blocks empty string inserts. Modifying nullability: ALTER TABLE ... MODIFY col NOT NULL or ALTER TABLE ... MODIFY col NULL.
Standard NOT NULL. The exception: INTEGER PRIMARY KEY columns implicitly get NOT NULL (and auto-increment behavior). SQLite allows ALTER TABLE to rename columns and add columns, but NOT NULL cannot be added to an existing column without recreating the table.