So we can create these tables that are completely empty waiting for us to put data inside of them.
Now, let's talk about how we do that.
How do we insert data?
Well, the answer is we use an insert statement.
It looks like this.
We use the keyword insert and then into a table name.
So for inserting into the cat's table, insert into cats.
And then we have parentheses and we specify the columns that we are inserting and in what order the
data will be expected.
So in other words, I'm going to say name, it's going to be first and then H and then down here, which
does not have to be on a second line.
It's just to fit it into the slides nicely.
We write values and then we have to follow that pattern.
Name is right there, Jetson H comes afterwards seven.
So we put them both in parentheses.
So this is a pair, in this case a pair of columns and then a pair of corresponding values.
So here are some other ways of writing this.
Just so you are aware, you can do it in one line.
You'll even see people space it out in some weird ways like this, it doesn't matter as long as there's
a semicolon at the end.
My SQL knows where the end of the entire statement is.
What really matters, though, is making sure you have the correct table name spelled correctly and
that you pay attention to the order that you list the different values in.
So I'm going to first insert from the command line.
So let's see what database I'm working in.
Okay, we're in the pet shop.
Fine.
Let's look at my cat table.
And I think I dropped that table, didn't I?
So I think I'm going to have to remake that table.
So let's do create table cats, which will have very simple stuff.
It's going to have name again is a var char.
This is basically recap from previous videos.
Age will be an int and that should be it.
So let's describe cats now.
There we go.
Name an age, let's insert a cat.
So insert into cats and then what am I going to insert into cats?
Well, first I'll give you the name.
Second, I'll give you the age and then I can hit enter if I want, just to work on a second line values.
And then I have to have name and then age.
So what should that name be?
Let's insert one of my cats that I have at home.
I've got a cat named Blue Steel and I don't know her age, honestly, she's like five or six at this
point.
So let's just leave it at that hit enter with my semicolon.
And I think it worked right.
It says one row affected query.
Okay.
In the next video, we'll learn how to check our work.
But let's insert one more row into our table.
But this time I'm going to do it over in one of my graphical interfaces.
So let's do it here in DB gates.
Although the process will be almost identical if you are working within what you call a SQL Workbench
MySQL Workbench.
So all I'm going to do is make sure I'm working in the pet Shop database.
We can see there's a cat's table there.
I'll comment this out and I'll just write Insert into cat and then name and then age values and let's
insert a different cat.
How about, I don't know, Jenkins, the cat who is seven years old.
So I'll run this entire file.
Execute it.
And we get a response back and it just says, Yeah, that worked.
Okay.
So we trust that it worked.
Until the next video, we'll take a look and make sure our values are in there.