Enforce non-nullability on a column.

Section: Schemas, Tables, and Core DDL

Set NOT NULL

sql
sql
ALTER TABLE public.users ALTER COLUMN email SET NOT NULL;
Explanation

Existing rows must already satisfy the constraint.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Schemas, Tables, and Core DDL
Add column
Add a nullable column to an existing table.
OpenIn sheetsqlsame section
Set column default
Change a column default value.
OpenIn sheetsqlsame section
Add check constraint
Add a named CHECK constraint.
OpenIn sheetsqlsame section
Create table
Create a basic table with primary key and defaults.
OpenIn sheetsqlsame section
Create identity column
Use a SQL-standard identity column instead of serial.
OpenIn sheetsqlsame section
Rename table
Rename a relation without recreating it.
OpenIn sheetsqlsame section