Now this video is going to be a slight departure.
We're still working with inserting data, but it's a slight side note, which has to do with something
called warnings.
So to illustrate what I'm describing here, if we tried to insert something that looks like this, so
we're going back to cats and our cats have a name and an age.
If we tried to insert a cat whose name is this gigantic string, this is a cat named Charlie, which
is also a human name.
In fact, I know a couple of Charlie's fun facts if we're trying to put that as this cat's name.
An age is just ten.
If we do that, let's go ahead and copy this just so I don't have to type that.
Make sure we have our cat's table.
Let's do describe cats.
So name and age.
Remember, there's this restriction here of 50.
I'm just going to paste that and put a semicolon.
I get something that says Query Oak, one row affected, one warning.
Just to double down on that, I pulled it out into a separate slide one morning.
Oh, my gosh.
What's going on?
Well, if we wanted to know what that warning was, we can use this command show warnings.
So we'll go back and type show warnings.
And I want you to pause and think, what is the warning?
If you were to guess, obviously, we haven't talked about it yet, but what do you think?
I'll see.
And the answer is, I get a warning here that says data truncated for column name.
So that corresponds to name here, which had a limit of 50 characters.
And this is more than 50 characters.
I can't remember how much it is, but it's more than 50.
And if we look at cats.
You'll see that our first of all, our table gets a little messed up here, but the string for name
gets cut off after this cat is named Charlie, which is also a.
And then the rest is gone.
So it's not like it's hidden and it's not displaying, it's just not stored at all.
So that's important to note.
So that's one warning that we saw there.
And that happened when our data was truncated.
Can you think of another warning we could generate deliberately?
What's something we could do that would give us a warning?
So pause the video or don't, but try and come up with something based off of what we have currently
set up for cats.
How could we insert something that would give us a warning?
All right, so what I was imagining is that we could try to insert something where we mixed up a data
type.
So let's say age instead of being an integer, we passed in some text random gibberish that should generate
a warning.
So let's try it now.
Insert into cats.
We'll do name first and then age
and name will just be Lima.
Why not?
But age will be gibberish like that, which is not a valid integer value.
We'll hit enter, we get one morning and we can view that warning with show warnings.
And this time it's a different warning.
It says incorrect integer value.
So the last one we saw said that name was truncated.
It was too long.
This one is telling us that incorrect integer value for column age.
So then here's a second thing for you to think about.
And you probably I mean, you'll just have to guess, but what do you think is stored inside of H.
Any ideas?
Well, if we do a select star from Cat, we can see we have Lima whose age is zero.
So in this case, if we screw something up, if we pass in some invalid data or a string instead of
number, it will automatically set age to be zero.
In a little bit, we'll see ways of changing that of changing that default.
But for now, it's zero.
Okay, so that's it for warnings at this point.
Just be aware that if you do see one warning or two warnings or however many warnings after a query
type show warnings and you'll be able to see your answer.
However, I actually forgot to mention this if we do something invalid, so let's do the same thing.
But instead of Lima, I'll call the cat Cusco.
I can't remember if there's a Z in that.
I don't know.
Okay.
Well, well, assume that there is so Cousteau with this crazy, crazy gibberish should give us a warning.
But if I do something in between, like select star from Cats and now I do show warnings.
Nothing.
Our warning set is empty, so this is just something to be aware of.
With that said, when you're creating applications using my SQL, that application, whatever you're
using, let's say we're using JavaScript or Ruby that will have ways of handling these warnings and
letting you know.
But when you're working in the shell like this, you have to use the show warnings command.
All right.
That's all there is to warnings.