Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
NOT NULL constraint
3. NOT NULL recap – trying to add a NULL value
Summary

Instruction

Great! Now let's make sure that our constraint works. We shouldn't be able to add a row with a NULL value in a NOT NULL column.

Exercise

We've created the campaign table for you. It has the following definition:

CREATE TABLE campaign (
  id integer PRIMARY KEY,
  name varchar(32),
  start_date date NOT NULL,
  budget decimal(6, 2)
);

Now run the code which tries to insert a row with a NULL start_date. What do you think will happen?

As you can see, the query failed. The constraint works correctly.