Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
UNIQUE
NOT NULL
15. NULL columns
CHECK
DEFAULT
Summary

Instruction

And... success. We did not specify that the columns were NOT NULL, so we could leave them without a value. In other words, if a column doesn't have the NOT NULL constraint, its value can be a NULL.

If you want, you can stress the fact that a certain column can be NULL by writing the keyword NULL after the column type:

CREATE TABLE rpg_game (
    id IDENTITY PRIMARY KEY,
    name varchar(32) UNIQUE NULL,
    genre varchar(32),
    classes_no int,
    complexity int,
    min_players int
);

The above code would work just as well without the NULL keyword. Its point is to draw the reader's attention to the fact that a column is NULLable.

Exercise

We've added the keyword NULL to every column in the table rpg_game except for the id column. Take your time and try to add a few rows without some of the NULLable columns. Observe what happens.