So to close out this section here, we're going to get a little practice with data types and the syntax
for creating and deleting tables.
So one more activity.
This time I'd like you to imagine that you work at a pastry shop, so you're going to manage and I manage
in air quotes that you can't see me doing right now, but you're going to manage a pastry shop in the
inventory for these pastries.
It's going to be very simplistic, but you'll need to create a pastries table and there should be at
least two columns.
If you want to add more, that's fine.
But a name for the pastry.
So what is it?
A croissant, a chocolate donut, whatever it is, as well as a quantity, which would be a number.
So I could go in and see that there are ten croissants or five chocolate crescents and so on, but we
won't fill it with data because we haven't seen it to do that.
So we're just defining the table in the columns.
So I'd like you to do that.
Then use a command to inspect your table and the columns using the MySQL command line interface.
So one of those short little commands we saw just to make sure, basically to check your work and then
lastly delete all that hard work, delete your table.
So pause the video if you'd like, go through this and come back when you're done and I'll be here.
So I'm back in cloud nine.
I'm actually still if I select database, I'm still using Cat app.
There are no tables in it right now because I deleted the cat's table, but I'm just going to put our
pastries table in here, even though it has nothing to do with Cat app, maybe it's a cat bakery or
something.
I've seen dog bakery, so maybe we're not too far off.
But anyways, it's just a silly exercise.
So we want to create a table, so create a table and then the name of the table will be pastries, plural,
then in parentheses.
And I'm going to do it on one line just to show you that it's not a problem.
So we'll have the name of the pastry.
And one thing that you may be tempted to do if you come from some other databases is to put a column
there.
That's something I find myself doing, just some from experience that I have some other tools, but
you don't want that there.
So if you see me doing that, hopefully I catch myself to create table pastries.
Name is going to be a var char and it should be 50 characters maximum.
So in parentheses 50.
And then we have age.
Excuse me, we have quantity.
And if you wanted to abbreviate that with just Q t y, which is what you'll see pretty commonly, you
could do that as well.
And that's just an integer.
Then we need our semicolon to end it.
We hit enter and we have a nice little error message.
So that was accidental.
I'm not going to try and play it off like it did it on purpose, but I am going to leave it in here
and that's mainly because it's something that pops up pretty commonly.
People aren't perfect, at least I'm not, especially when I'm recording.
Got a lot of stuff to worry about.
Can you identify what went wrong?
To give you a hint.
I'm just missing one character.
Yup.
If you got it.
I'm missing a comma here, and the error messages aren't always that useful, but it tells me there's
an error in my syntax.
And it's something near quantity.
INT So right before that, I'm missing a comma and it's treating all of this as name, which is wrong.
We need that comma there so we can recall the line.
Go back.
And insert our comma.
Now when we do it, we get Query OC and we'll move on to the next part, which was to make sure things
worked so we could either do show tables and then we can do show.
Let's do describe.
Describe pastries.
Perfect name var quantity is an int and the last thing was to drop our pastries.
Table drop table.
Pastries.
Goodbye pastries.
And just to verify it worked.
Let's do show tables again and there's nothing here.
Perfect.
So the next section is all going to be about inserting data.
We make tables.
They're empty.
How do we get stuff in there?