WEBVTT

00:00.200 --> 00:03.170
This video we're going to answer a simple question.

00:03.450 --> 00:10.760
Back when we typed describe table names to describe cats What's up with this part.

00:10.960 --> 00:11.580
What is this.

00:11.590 --> 00:15.010
No column here in this little table.

00:15.010 --> 00:18.540
And why is there to is for name and age.

00:19.000 --> 00:20.500
So this video is all about.

00:20.520 --> 00:20.940
No.

00:20.980 --> 00:22.100
The concept of No.

00:22.240 --> 00:24.500
I've been working with no sequel.

00:24.820 --> 00:31.490
So to start off let's talk about what NO means NO basically means that the value is on known.

00:31.500 --> 00:36.430
It's sequels way of saying I don't know what this is or there is no specified value.

00:36.610 --> 00:39.570
An important note is that it does not mean zero.

00:39.670 --> 00:41.730
Some people often think no means zero.

00:41.730 --> 00:43.600
It doesn't in this context.

00:43.600 --> 00:48.910
So to illustrate the significance of these having a yes here it basically means that these are permitted

00:48.910 --> 00:49.960
to be No.

00:50.170 --> 00:54.780
It's OK if they have an unknown value and that's that happens by default.

00:54.790 --> 00:57.680
To illustrate though that that is the case.

00:57.960 --> 01:00.190
Here's a little bit of code right now.

01:00.220 --> 01:01.960
We could run this command.

01:02.290 --> 01:09.460
We have a catch table with name and age but we could do insert into cats and only specify a name.

01:09.520 --> 01:15.340
And in this case I used Alabama not sure who named her cat Alabama but you could probably say who names

01:15.340 --> 01:20.600
are cat blue which is what I named my cat so we could run this command.

01:20.610 --> 01:23.220
And Age has no specified value.

01:23.230 --> 01:25.750
So in fact let's try it right now.

01:25.810 --> 01:29.360
Make some space inserts into cats.

01:31.640 --> 01:33.010
Name.

01:34.600 --> 01:39.100
Values is the siren.

01:40.190 --> 01:49.740
Our Bama just like that we don't get any warnings or anything saying that name her that age is empty.

01:49.740 --> 01:50.830
Nothing like that.

01:51.060 --> 01:59.140
Now would you like star from cat you'll see that we have a new cat whose name is Alabama.

01:59.400 --> 02:00.810
But age is no.

02:01.050 --> 02:09.120
And again that's because we have no oil as a permitted value or it's technically not of value but age

02:09.150 --> 02:10.240
is allowed to be no.

02:10.350 --> 02:15.620
So his name so I could do the same thing or an even more extreme version.

02:15.720 --> 02:21.340
I could run this insert into cats nothing values nothing.

02:21.620 --> 02:32.190
You know if I did that take a moment to guess insert into cats nothing values nothing.

02:32.220 --> 02:33.640
What do you think will happen.

02:34.300 --> 02:36.280
Let's do a select star.

02:36.480 --> 02:40.230
Now we have cat no name no age no.

02:40.440 --> 02:43.050
So then the question becomes how do we prevent that.

02:43.050 --> 02:47.430
How do we require that name is not know and that age is not enough.

02:48.000 --> 02:51.800
And the answer is not no.

02:52.120 --> 02:59.080
So what we can do is specify when we actually define a table that something let's say a field like name

02:59.620 --> 03:00.770
is not all.

03:01.210 --> 03:03.070
And we use this syntax right here.

03:03.250 --> 03:11.250
So here's an example for a cat to table and I'll be using this convention Cat 2 Cat 3.

03:11.560 --> 03:19.160
So in a cat to table or 2.00 version when we define it we would say name is Vardar.

03:19.180 --> 03:24.760
This time I use 100 but the limit doesn't matter really followed by not no.

03:25.300 --> 03:29.280
So that means that it will not be permitted to be empty.

03:29.650 --> 03:34.990
And then age is also an IT age is an integer who is also not no.

03:35.590 --> 03:42.690
So if we try that right now I'm going to create a table Kappes too.

03:43.150 --> 03:53.820
And we're going to have and I'll do this on separate lines name is Vardar 100.

03:54.180 --> 03:54.920
It's OK.

03:55.000 --> 04:03.620
This one you can have longer names and then you have not know followed by age.

04:03.680 --> 04:10.320
Isn't it also not know what hit enter.

04:10.320 --> 04:22.390
Now let's start off by using describe cats to this time under no for both fields says no.

04:22.430 --> 04:26.200
So that's one way to tell that these are not allowed to be No.

04:26.540 --> 04:29.500
And just to emphasize this I made a slide.

04:29.540 --> 04:30.570
Notice the difference here.

04:30.710 --> 04:34.050
So now let's actually put it to the test.

04:34.100 --> 04:43.610
Let's try to insert into Cat 2 and this time will only do name and we'll leave off age and then we'll

04:43.610 --> 04:49.310
have values and name for this one will be Texas.

04:49.320 --> 04:51.960
In keeping with the state theme.

04:52.570 --> 04:53.400
OK.

04:54.050 --> 04:55.830
What do you think will happen.

04:55.940 --> 04:59.540
Insert into cats where age is not allowed.

04:59.600 --> 05:09.020
No but we're not specifying age so it says queery OK we didn't get an error message and we got a warning.

05:09.280 --> 05:12.730
So let's do show warnings warning field.

05:12.790 --> 05:15.340
Age doesn't have a default value.

05:15.610 --> 05:20.600
So what it's telling me is that I left age off I didn't specify it.

05:20.710 --> 05:22.600
So what it was going to do is make it no.

05:22.750 --> 05:25.120
But then no not allowed to be no.

05:25.240 --> 05:31.060
So I need to go find a default value and there's not a default value specified.

05:31.060 --> 05:37.220
So if we look you can probably guess her next or next video will be on default values.

05:37.330 --> 05:44.930
But if we do select star from Cat 2 you can see it automatically defined 0.

05:45.250 --> 05:50.620
So the next video we'll talk about why that happened but the way that it works if it's not allowed we

05:50.620 --> 05:53.650
know you don't have a default it's going to be zero.

05:53.650 --> 06:02.800
Now let's try the same thing with insert into Cat 2 and this time only age is specified and age will

06:02.800 --> 06:07.990
be 7 I get the same query OK.

06:07.990 --> 06:10.800
One morning show warnings.

06:11.290 --> 06:14.640
This time it says field name doesn't have a default value.

06:15.950 --> 06:17.720
Let's do our select star.

06:17.720 --> 06:20.800
Notice what we get right here earlier.

06:20.990 --> 06:22.780
See how far back I can go.

06:22.790 --> 06:24.140
We had no.

06:24.380 --> 06:30.040
1 we didn't specify a name when we inserted into cats just regular cats not cats too.

06:30.410 --> 06:33.830
But now when I don't specify a name it doesn't say no.

06:34.100 --> 06:36.090
And this is an empty string.

06:36.140 --> 06:37.520
So there's a difference.

06:37.520 --> 06:39.760
No means that there is no value at all.

06:39.770 --> 06:47.410
We didn't specify empty string is just a type of a VAR char that just has nothing in it.

06:47.690 --> 06:50.340
So you can think of it as this basically.

06:50.340 --> 06:54.260
OK so next we'll talk about how we specify these default values.
