Inserting data
3. Insert NULL values

Instruction

Well done! You can use the NULL value explicitly in an INSERT statement. To insert, again, Chris of unknown age as a user with id 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 table user, you can simply use this command:

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

Which way to 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 on typing, omit the column name.

Exercise

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

Stuck? Here's a hint!

Type

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