1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00
Files
til/postgres/remove-not-null-constraint-from-a-column.md

637 B

Remove Not Null Constraint From A Column

When you want to add a not null constraint to a column, you do so by setting it.

alter table books
  alter column publication_date
  set not null;

You can remove a not null constraint from a column, by dropping it.

alter table books
  alter column publication_date
  drop not null;

Notice this excerpt of syntax from the official Postgres docs:

... ALTER [ COLUMN ] column_name { SET | DROP } NOT NULL

source