So now that we've learned how tables work and we've seen a little bit about data types, we finally
get to start creating tables.
So here is the magic syntax for creating a new table in my SQL.
Here is the generic version.
So it's create table and then the name of the table.
So cats or users or people or results or whatever it is.
And then in parentheses.
A column name and then a space and the data type.
And there are a few other things that can come along with the data type, but for now we're just talking
about data type.
So a column name like age is an INT.
Or address is a var cha or var kah however you want to pronounce it.
So that's the main idea.
And you keep listing these columns as many as you need.
It could just be one, it could be 20.
And you separate them by columns, excuse me, by commas.
And then when you finish, you add your semicolon, and that's that.
Now you don't have to format it this way on separate lines, but I think it's easiest to understand.
It's definitely easier to read when you get much more complex ones, but you could do it all in a single
line, just like anything else in my SQL.
So here's an actual example using our cat's table.
So we're just working with name and age.
Create table cats.
One thing I should point out is that table names should be plural sized, so it doesn't actually matter
for the mechanics or behind the scenes.
It won't change anything.
But you want to just follow this convention use plural, because that's what a table describes as multiple
cats.
Or people instead of person.
Or payment instead of payment.
And so on.
So we have parentheses, and then we list our columns and their corresponding data types.
So name will be a var char with a 100 character limit.
Comma age will be an integer.
So let's hop over to cloud nine and see if it works.
So the first thing I'll do is just make a new database.
You don't have to do this if you're following along, but I'll just call one cat app.
Oops.
Forgot my semicolon.
Then we will use.
Okay.
So now the next thing we'll do is create table cat.
And then we can either do parentheses here.
And that's what I usually do when I'm working in the MySQL command line or in the shell.
So you don't have to worry about spaces too much.
So create table cats and then we'll say name is a var char 100 comma age is an int and then we'll close
our parentheses with the semicolon.
Query OC the zero rows affected.
Perfect.
It appears to have worked.
Or at least we have to trust that it works.
Because right now we don't have a way of testing that.
But we will in the next video cliffhanger.