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.

Compatibility

Show:
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.

Details

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 Syntax

CREATE TABLE users ( id INT NOT NULL PRIMARY KEY, email TEXT NOT NULL, bio TEXT NULL -- explicit NULL (optional) );

Version Support

MySQL: Since all PostgreSQL: Since all SQL Server: Since all Oracle: Since all SQLite: Since all

Per-Database Syntax & Notes

MySQL

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.

CREATE TABLE users ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL, bio TEXT NULL ); -- Enable strict mode (recommended): SET sql_mode = 'STRICT_ALL_TABLES'; -- Add NOT NULL to existing column: ALTER TABLE users MODIFY COLUMN bio TEXT NOT NULL DEFAULT '';

PostgreSQL

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+.

CREATE TABLE users ( id SERIAL PRIMARY KEY, email TEXT NOT NULL, bio TEXT ); -- Add NOT NULL to existing column: ALTER TABLE users ALTER COLUMN email SET NOT NULL; -- Remove NOT NULL: ALTER TABLE users ALTER COLUMN email DROP NOT NULL;

SQL Server

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.

CREATE TABLE users ( id INT NOT NULL IDENTITY PRIMARY KEY, email NVARCHAR(255) NOT NULL, bio NVARCHAR(MAX) NULL ); -- Change nullability: ALTER TABLE users ALTER COLUMN email NVARCHAR(255) NOT NULL; -- If NULLs exist, update first: UPDATE users SET email = '' WHERE email IS NULL; ALTER TABLE users ALTER COLUMN email NVARCHAR(255) NOT NULL;

Oracle

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.

CREATE TABLE users ( id NUMBER NOT NULL PRIMARY KEY, email VARCHAR2(255) NOT NULL, bio VARCHAR2(4000) ); -- Change nullability: ALTER TABLE users MODIFY email VARCHAR2(255) NOT NULL; ALTER TABLE users MODIFY bio VARCHAR2(4000) NULL;

SQLite

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.

CREATE TABLE users ( id INTEGER PRIMARY KEY, -- implicitly NOT NULL email TEXT NOT NULL, bio TEXT -- nullable );