WEBVTT

00:07.850 --> 00:10.730
I will call you back again to another video lecture and mic call.

00:10.730 --> 00:15.830
And in this video lecture is called Head and Lane but not no constraint.

00:16.370 --> 00:20.300
Alright, so the previous lecture I was able to teach you about a unique constraint and we can see how

00:20.300 --> 00:21.290
that played out.

00:21.290 --> 00:23.600
And I hope you practice that.

00:23.600 --> 00:28.670
And let's go ahead and learn about another constraint known as not null constraint.

00:28.880 --> 00:33.560
And let's go ahead and say the previous table we created, which is employee table I is no longer a

00:33.560 --> 00:35.150
variable because I've dropped the table.

00:35.180 --> 00:37.430
Now let's go ahead and recreate that exact table.

00:37.430 --> 00:42.620
So instead of wasting our time typing this one by one, let's go ahead and put the table back in here.

00:42.620 --> 00:45.380
And that is the table that we have in the previous lecture.

00:45.380 --> 00:47.420
And that contains the unique constraint.

00:47.450 --> 00:49.910
So go ahead and remove the unique constraint right now.

00:50.150 --> 00:58.520
So if I want to add a not null constraint maybe I would add that to salary or first name or employee.

00:58.550 --> 01:04.210
What I need to do is that I'll go over to salary and I'll go ahead and add not not.

01:04.210 --> 01:08.020
So this salary will never, ever be known.

01:08.050 --> 01:08.710
All right.

01:08.710 --> 01:10.510
So that is what I'm going to do.

01:10.540 --> 01:15.370
You can add that to first name or to employee ID or any other column you've just created.

01:15.400 --> 01:18.850
Now let's go ahead and create this table by putting all this.

01:18.850 --> 01:21.130
So down here you can see I've created this table.

01:21.160 --> 01:21.670
All right.

01:21.700 --> 01:25.180
Now let's go ahead and view the table we just created.

01:25.180 --> 01:36.580
So go ahead and say select all from employees can apply semicolon at the end.

01:36.610 --> 01:38.200
And go ahead and hit on this.

01:38.200 --> 01:42.400
And this is where we have employee ID first name and salary.

01:42.430 --> 01:44.350
Now we've just created this.

01:44.350 --> 01:47.680
And now what if like we have the students table.

01:47.710 --> 01:48.760
Go ahead and refresh this.

01:48.790 --> 01:50.500
We have the previous table right in here.

01:50.500 --> 01:56.650
So the students table right now if you want to do that let me go ahead and show you using the employees

01:56.650 --> 01:57.310
table.

01:57.340 --> 01:58.810
Go ahead and remove this.

01:58.810 --> 02:02.180
And let's go ahead and insert some data right in here.

02:02.180 --> 02:05.810
So the previously we created some data and that is it right in here.

02:05.810 --> 02:08.630
So tables employees and that is employee ID.

02:08.780 --> 02:10.730
And this is what we have.

02:10.760 --> 02:12.020
This is the table created.

02:12.050 --> 02:16.160
Now I want to enter some data which is the previous data we created.

02:16.190 --> 02:18.050
Go ahead and put that back.

02:18.050 --> 02:22.220
So I have this data set for you Will because I'm going to download that from the resource folder.

02:22.310 --> 02:25.250
Go ahead and download that and that it is right in there.

02:25.250 --> 02:27.320
So this is the data we have.

02:27.320 --> 02:32.570
And I want to insert this data right in here and have inserted that data.

02:32.600 --> 02:37.550
Let's go ahead and select all from.

02:39.860 --> 02:43.490
Employees put a semicolon at the end and let's go ahead and check it out.

02:43.490 --> 02:45.650
So now we can see that right in here.

02:45.710 --> 02:48.890
Go ahead and bring this down so you can see everything.

02:48.890 --> 02:51.260
So we have this data.

02:51.260 --> 02:54.320
And I want to apply the not null.

02:54.350 --> 02:56.480
Maybe I want to add that to salary.

02:56.510 --> 03:01.000
What I need to do is I go warhead and or Tardis.

03:01.690 --> 03:03.520
Uh, table.

03:03.520 --> 03:10.480
So what I need to go ahead and do is that I gotta say alter table, then give the name of the table,

03:10.480 --> 03:12.340
and that is employees.

03:12.490 --> 03:17.200
And, uh, I'll go ahead and say modify.

03:17.410 --> 03:17.950
All right.

03:17.950 --> 03:18.970
So modify.

03:19.000 --> 03:23.800
Remember that I did not know and I can add that to salary.

03:23.830 --> 03:25.810
So I'm going to say salary.

03:25.810 --> 03:34.270
And uh that is int and not know the semicolon at the end.

03:34.270 --> 03:36.580
And let's go ahead and execute this query.

03:36.610 --> 03:44.800
Now let's go ahead and check out and see you can see that uh employees modify salary has been added

03:44.800 --> 03:45.520
not known.

03:45.520 --> 03:49.210
And that is what we have with the previously okay.

03:49.240 --> 03:53.890
Now that is a way you can do that for a table that hasn't existed.

03:53.890 --> 03:55.810
And you have added some data right in there.

03:55.840 --> 04:02.720
Now let's go ahead and check if this actually works by updating or inserting a new data.

04:02.750 --> 04:03.980
This guy had to remove this.

04:03.980 --> 04:11.750
I'll go ahead and insert a new insert into employee.

04:13.880 --> 04:15.650
So insert into employees.

04:15.650 --> 04:17.450
Let's go ahead and add the value.

04:17.480 --> 04:19.310
Go ahead and add values.

04:19.730 --> 04:26.510
And I'm going to add the very first one because we have the next id is five.

04:26.510 --> 04:31.160
And let's the name be mirrored.

04:31.190 --> 04:31.790
Oh wow.

04:31.790 --> 04:34.220
That is mirror.

04:34.250 --> 04:37.280
All right so and the mirror I'm going to add it to be.

04:37.280 --> 04:39.860
No I remember I made this array not to be.

04:39.860 --> 04:40.250
No.

04:40.280 --> 04:40.730
All right.

04:40.730 --> 04:42.770
So I believe comma at the end.

04:42.860 --> 04:45.710
And drag this up so it can be good to see that.

04:45.710 --> 04:47.630
And I go ahead and run this.

04:47.630 --> 04:50.210
And now here you can see you have an error.

04:50.240 --> 04:54.080
You cannot have an you have an error in your SQL syntax.

04:54.110 --> 04:54.620
Okay.

04:54.650 --> 04:59.080
So let's go ahead and it says Murano.

04:59.080 --> 05:00.880
And that is not possible.

05:00.880 --> 05:01.990
So why?

05:02.740 --> 05:05.140
Because I'm getting a different error right in the air.

05:05.380 --> 05:07.990
Go ahead and check out this again.

05:07.990 --> 05:11.830
And it says quorum salary cannot be known.

05:11.860 --> 05:17.620
So you can see that you cannot be know because the first error shows that there is no comma right in

05:17.620 --> 05:17.890
here.

05:17.920 --> 05:22.870
It says that my SQL, uh syntax has an error.

05:22.900 --> 05:25.300
That is why I knew that I didn't put a comma.

05:25.330 --> 05:26.440
I want to add a comma.

05:26.470 --> 05:31.750
I try to execute the query and it says salary cannot be null.

05:32.410 --> 05:33.640
So you can see that.

05:33.640 --> 05:38.080
And let's go ahead and select these.

05:38.620 --> 05:44.200
So if I go ahead and select this we'll go ahead and see what we have right in there.

05:44.710 --> 05:48.400
Select all from.

05:52.150 --> 05:55.030
Employees and go ahead and run this.

05:55.060 --> 05:56.050
Let's check it out.

05:56.410 --> 05:59.030
So because of the not knowing, we're not getting anything.

05:59.030 --> 06:02.120
And the only way to do this, maybe I don't want to add anything.

06:02.120 --> 06:04.280
I can go ahead and put a zero right in there.

06:04.280 --> 06:06.680
And now let's go ahead and run this and check it out.

06:07.010 --> 06:08.090
Go ahead and drag this.

06:08.120 --> 06:10.850
You can see that our code has executed successfully.

06:11.000 --> 06:13.280
Go ahead and drag this down.

06:13.850 --> 06:16.760
And I want to drag this up so I can be able to see our table.

06:17.210 --> 06:19.280
And I can see me around is zero.

06:19.280 --> 06:22.070
But Mira can never be null.

06:22.400 --> 06:27.950
So there is a way we use a null, not null constraint in MySQL.

06:27.950 --> 06:29.630
So go ahead and check it out.

06:29.660 --> 06:30.440
Practice with it.

06:30.440 --> 06:33.260
You can add to an F-16 data.

06:33.560 --> 06:36.740
You can also add it when you're inserting a new data into your table.

06:36.740 --> 06:38.450
So go ahead and practice with it.

06:38.450 --> 06:42.380
And when you're updating you can also also check it out.

06:42.380 --> 06:43.640
So thank you so much.

06:43.640 --> 06:46.490
And I'm going to see you in the next video lecture.
