Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Inserting data
5. Insert NULL values
Modifying data
Deleting data
CRUD

Instruction

Well done! You can use the NULL value explicitly in an INSERT statement. To insert Chris of unknown age as a user with an ID of 6, you can use the command:

INSERT INTO user (id, name, age) VALUES
(6, 'Chris', NULL);

Or, since the command defines values for all columns in the user table, you can simply use this command:

INSERT INTO user VALUES
(6, 'Chris', NULL);

Which way should you choose: the one presented in the previous exercise or one of the ways shown here? It's entirely up to you! If you want to emphasize that you insert a NULL value, insert it explicitly. If you want to save some typing, omit the column name.

Exercise

Add the starter Kosovo Bread with ID 10 again to the dish table. This time, explicitly insert a NULL value into the price column.

Stuck? Here's a hint!

Type:

INSERT INTO dish VALUES
(10, 'starter', 'Kosovo Bread', NULL);