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

Instruction

Great. Let's proceed to our second constraint: NOT NULL, and our second game type: RPG. Take a look at the following example:

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

As you can see, we've added a new keyword NOT NULL after the type of the column. Its meaning should be quite clear: the value in the specific column cannot be a NULL. In other words - we must provide a value in the column for each row.

Exercise

As you could see in the example, we introduced a new type of game: rpg games. Now, we store the following information: id of the game, its name, genre, number of playable character classes (column classes_no), the complexity of the system (a score from 0 to 10) and the minimal number of players.

Select all the content from the new table rpg_game and study the values for the column name. A you can see, there are no NULL values.

Stuck? Here's a hint!

Type

SELECT *
FROM rpg_game;