From the course: MySQL Database Administration

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

The NOT NULL constraint

The NOT NULL constraint

- [Instructor] All right, next we're going to be talking about the NON-NULL constraint. Sometimes we want certain columns to be populated for every single record that ever gets written to that table. We can prescribe this by applying a NON-NULL constraint to a certain column, which will then require that any record that ever gets added has to have a value. If the NON-NULL constraint is on a column and someone tries to INSERT a record without including a value for that column, the INSERT will fail. This is a great way to preserve the integrity of your data, so if you know that you'll always need to have a value for a certain column, go ahead and put the NON-NULL constraint on and that will make sure that no records can get added without that value. Let's jump into Workbench and I'll walk through an example to make this concrete. All right, so the example here that we'll go through is the inventory table, and let's just have a quick refresher of what's in here. We've got inventory_id…

Contents