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

Instruction

Alright. We'll start off with UNIQUE. This constraint means that the values in a given column must be... well, unique. In other words, you can't have more than one row with the same value in such columns. Take a look at our instruction:

CREATE TABLE board_game (
    id IDENTITY PRIMARY KEY,
    name varchar(32) UNIQUE,
    genre varchar(32),
    min_players int,
    min_age int,
    price decimal(5,2)
);

As you can see, the column name has the UNIQUE constraint. It is placed after the type of the column.

Exercise

Our users added some games to the table board_game. Select all the information from the table and study the column name.

As you will see, all the values are unique and each of them appears only once.

Stuck? Here's a hint!

Type

SELECT *
FROM board_game;