This video we're going to answer a simple question.
Back when we typed describe table names to describe cats What's up with this part.
What is this.
No column here in this little table.
And why is there to is for name and age.
So this video is all about.
No.
The concept of No.
I've been working with no sequel.
So to start off let's talk about what NO means NO basically means that the value is on known.
It's sequels way of saying I don't know what this is or there is no specified value.
An important note is that it does not mean zero.
Some people often think no means zero.
It doesn't in this context.
So to illustrate the significance of these having a yes here it basically means that these are permitted
to be No.
It's OK if they have an unknown value and that's that happens by default.
To illustrate though that that is the case.
Here's a little bit of code right now.
We could run this command.
We have a catch table with name and age but we could do insert into cats and only specify a name.
And in this case I used Alabama not sure who named her cat Alabama but you could probably say who names
are cat blue which is what I named my cat so we could run this command.
And Age has no specified value.
So in fact let's try it right now.
Make some space inserts into cats.
Name.
Values is the siren.
Our Bama just like that we don't get any warnings or anything saying that name her that age is empty.
Nothing like that.
Now would you like star from cat you'll see that we have a new cat whose name is Alabama.
But age is no.
And again that's because we have no oil as a permitted value or it's technically not of value but age
is allowed to be no.
So his name so I could do the same thing or an even more extreme version.
I could run this insert into cats nothing values nothing.
You know if I did that take a moment to guess insert into cats nothing values nothing.
What do you think will happen.
Let's do a select star.
Now we have cat no name no age no.
So then the question becomes how do we prevent that.
How do we require that name is not know and that age is not enough.
And the answer is not no.
So what we can do is specify when we actually define a table that something let's say a field like name
is not all.
And we use this syntax right here.
So here's an example for a cat to table and I'll be using this convention Cat 2 Cat 3.
So in a cat to table or 2.00 version when we define it we would say name is Vardar.
This time I use 100 but the limit doesn't matter really followed by not no.
So that means that it will not be permitted to be empty.
And then age is also an IT age is an integer who is also not no.
So if we try that right now I'm going to create a table Kappes too.
And we're going to have and I'll do this on separate lines name is Vardar 100.
It's OK.
This one you can have longer names and then you have not know followed by age.
Isn't it also not know what hit enter.
Now let's start off by using describe cats to this time under no for both fields says no.
So that's one way to tell that these are not allowed to be No.
And just to emphasize this I made a slide.
Notice the difference here.
So now let's actually put it to the test.
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
have values and name for this one will be Texas.
In keeping with the state theme.
OK.
What do you think will happen.
Insert into cats where age is not allowed.
No but we're not specifying age so it says queery OK we didn't get an error message and we got a warning.
So let's do show warnings warning field.
Age doesn't have a default value.
So what it's telling me is that I left age off I didn't specify it.
So what it was going to do is make it no.
But then no not allowed to be no.
So I need to go find a default value and there's not a default value specified.
So if we look you can probably guess her next or next video will be on default values.
But if we do select star from Cat 2 you can see it automatically defined 0.
So the next video we'll talk about why that happened but the way that it works if it's not allowed we
know you don't have a default it's going to be zero.
Now let's try the same thing with insert into Cat 2 and this time only age is specified and age will
be 7 I get the same query OK.
One morning show warnings.
This time it says field name doesn't have a default value.
Let's do our select star.
Notice what we get right here earlier.
See how far back I can go.
We had no.
1 we didn't specify a name when we inserted into cats just regular cats not cats too.
But now when I don't specify a name it doesn't say no.
And this is an empty string.
So there's a difference.
No means that there is no value at all.
We didn't specify empty string is just a type of a VAR char that just has nothing in it.
So you can think of it as this basically.
OK so next we'll talk about how we specify these default values.