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 - MySQL Tutorial
From the course: MySQL Database Administration
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Creating an index4m 41s
-
(Locked)
The UNIQUE constraint4m 8s
-
(Locked)
The NOT NULL constraint3m 59s
-
(Locked)
Challenge: Indexes and constraints1m 12s
-
(Locked)
Solution: Indexes and constraints9m 24s
-
(Locked)
Stored procedures6m 27s
-
(Locked)
Challenge: Stored procedures2m 3s
-
(Locked)
Solution: Stored procedures4m 23s
-
(Locked)
Triggers7m 50s
-
(Locked)
Challenge: Triggers1m 41s
-
(Locked)
Solution: Triggers5m 8s
-
(Locked)
-
-