NOT NULL and UNIQUE
NOT NULL makes a column required. UNIQUE stops two rows having the same value. The database rejects any row that breaks the rule with an error.
Example
CREATE TABLE accounts (
id INTEGER PRIMARY KEY,
email TEXT NOT NULL UNIQUE
);
INSERT INTO accounts (email) VALUES ('ada@example.com');
INSERT INTO accounts (email) VALUES ('tunde@example.com');
SELECT * FROM accounts;Result
id | email 1 | ada@example.com 2 | tunde@example.com
Exercise
Make the column required.
email TEXT NOT Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.