Tsallaka zuwa abun ciki
Justice Tech School

CHECK and DEFAULT

CHECK rejects values that break a condition, such as a score outside 0 to 100. DEFAULT supplies a value when you do not give one.

Example
CREATE TABLE quiz_results (
  id INTEGER PRIMARY KEY,
  score INTEGER CHECK (score BETWEEN 0 AND 100),
  status TEXT DEFAULT 'pending'
);
INSERT INTO quiz_results (score) VALUES (88);
SELECT * FROM quiz_results;

Result

id | score | status
1  | 88    | pending

Exercise

Give the column a starting value.

status TEXT  'pending'

Quiz Test

What does CHECK do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.