Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
CHECK constraints with a simple condition
5. CHECK – practice
CHECK constraints with complex conditions
Adding CHECK constraints to existing tables
Summary

Instruction

As you can see, the database protects the columns from any invalid values, even when updating the row. The price must be greater than 0, so when you try to update a row and provide a price lower than 0, the database will not allow it.

Good news, isn't it? But before we move on, how about creating your own CHECK constraints?

Exercise

It's your turn to create the table with CHECKs! Use the template we provided and make sure the hours and price values are both greater than zero.

Remember to put the CHECK keyword after the data type for each column, followed by the logical condition in parenthesis.

Stuck? Here's a hint!

Make sure that (hours > 0 and price > 0.