I will call you back again to another video lecture and mic call.
And in this video lecture is called Head and Lane but not no constraint.
Alright, so the previous lecture I was able to teach you about a unique constraint and we can see how
that played out.
And I hope you practice that.
And let's go ahead and learn about another constraint known as not null constraint.
And let's go ahead and say the previous table we created, which is employee table I is no longer a
variable because I've dropped the table.
Now let's go ahead and recreate that exact table.
So instead of wasting our time typing this one by one, let's go ahead and put the table back in here.
And that is the table that we have in the previous lecture.
And that contains the unique constraint.
So go ahead and remove the unique constraint right now.
So if I want to add a not null constraint maybe I would add that to salary or first name or employee.
What I need to do is that I'll go over to salary and I'll go ahead and add not not.
So this salary will never, ever be known.
All right.
So that is what I'm going to do.
You can add that to first name or to employee ID or any other column you've just created.
Now let's go ahead and create this table by putting all this.
So down here you can see I've created this table.
All right.
Now let's go ahead and view the table we just created.
So go ahead and say select all from employees can apply semicolon at the end.
And go ahead and hit on this.
And this is where we have employee ID first name and salary.
Now we've just created this.
And now what if like we have the students table.
Go ahead and refresh this.
We have the previous table right in here.
So the students table right now if you want to do that let me go ahead and show you using the employees
table.
Go ahead and remove this.
And let's go ahead and insert some data right in here.
So the previously we created some data and that is it right in here.
So tables employees and that is employee ID.
And this is what we have.
This is the table created.
Now I want to enter some data which is the previous data we created.
Go ahead and put that back.
So I have this data set for you Will because I'm going to download that from the resource folder.
Go ahead and download that and that it is right in there.
So this is the data we have.
And I want to insert this data right in here and have inserted that data.
Let's go ahead and select all from.
Employees put a semicolon at the end and let's go ahead and check it out.
So now we can see that right in here.
Go ahead and bring this down so you can see everything.
So we have this data.
And I want to apply the not null.
Maybe I want to add that to salary.
What I need to do is I go warhead and or Tardis.
Uh, table.
So what I need to go ahead and do is that I gotta say alter table, then give the name of the table,
and that is employees.
And, uh, I'll go ahead and say modify.
All right.
So modify.
Remember that I did not know and I can add that to salary.
So I'm going to say salary.
And uh that is int and not know the semicolon at the end.
And let's go ahead and execute this query.
Now let's go ahead and check out and see you can see that uh employees modify salary has been added
not known.
And that is what we have with the previously okay.
Now that is a way you can do that for a table that hasn't existed.
And you have added some data right in there.
Now let's go ahead and check if this actually works by updating or inserting a new data.
This guy had to remove this.
I'll go ahead and insert a new insert into employee.
So insert into employees.
Let's go ahead and add the value.
Go ahead and add values.
And I'm going to add the very first one because we have the next id is five.
And let's the name be mirrored.
Oh wow.
That is mirror.
All right so and the mirror I'm going to add it to be.
No I remember I made this array not to be.
No.
All right.
So I believe comma at the end.
And drag this up so it can be good to see that.
And I go ahead and run this.
And now here you can see you have an error.
You cannot have an you have an error in your SQL syntax.
Okay.
So let's go ahead and it says Murano.
And that is not possible.
So why?
Because I'm getting a different error right in the air.
Go ahead and check out this again.
And it says quorum salary cannot be known.
So you can see that you cannot be know because the first error shows that there is no comma right in
here.
It says that my SQL, uh syntax has an error.
That is why I knew that I didn't put a comma.
I want to add a comma.
I try to execute the query and it says salary cannot be null.
So you can see that.
And let's go ahead and select these.
So if I go ahead and select this we'll go ahead and see what we have right in there.
Select all from.
Employees and go ahead and run this.
Let's check it out.
So because of the not knowing, we're not getting anything.
And the only way to do this, maybe I don't want to add anything.
I can go ahead and put a zero right in there.
And now let's go ahead and run this and check it out.
Go ahead and drag this.
You can see that our code has executed successfully.
Go ahead and drag this down.
And I want to drag this up so I can be able to see our table.
And I can see me around is zero.
But Mira can never be null.
So there is a way we use a null, not null constraint in MySQL.
So go ahead and check it out.
Practice with it.
You can add to an F-16 data.
You can also add it when you're inserting a new data into your table.
So go ahead and practice with it.
And when you're updating you can also also check it out.
So thank you so much.
And I'm going to see you in the next video lecture.