WEBVTT

00:00.270 --> 00:05.940
So now that we've learned how tables work and we've seen a little bit about data types we finally get

00:05.940 --> 00:08.040
to start creating tables.

00:08.040 --> 00:13.120
So here is the magic syntax for creating a new table in my school.

00:13.140 --> 00:15.070
Here is the generic version.

00:15.180 --> 00:19.140
So it's create table and then the name of the table.

00:19.170 --> 00:23.790
So cats or users or people or results or whatever it is.

00:23.910 --> 00:30.510
And then in parentheses a column name and then MySpace and that data type.

00:30.510 --> 00:34.710
And there are a few other things that can come along with the data type but for now we're just talking

00:34.710 --> 00:35.790
about data type.

00:35.790 --> 00:44.780
So a column name like age is an ENT or address is of our chart or our car however you want to pronounce

00:44.780 --> 00:45.840
it.

00:45.920 --> 00:47.180
So that's the main idea.

00:47.450 --> 00:53.240
And you keep listing these columns as many as you need it could just be one it could be 20 and you separate

00:53.240 --> 01:00.050
them by columns excuse me by commas and then when you finish you add your semi-colon and that's that.

01:00.200 --> 01:06.060
And you don't have to format it this way on separate lines but I think it's easiest to understand.

01:06.200 --> 01:11.330
It's definitely easier to read when you get much more complex ones but you could do it all on a single

01:11.330 --> 01:14.160
line just like anything else in my as well.

01:14.450 --> 01:17.810
So here's an actual example using our catch table.

01:17.990 --> 01:22.850
So we're just working with name and age create table cats.

01:23.120 --> 01:28.640
One thing I should point out is that table names should be pluralized so it doesn't actually matter

01:28.660 --> 01:31.750
for the mechanics or behind the scenes that won't change anything.

01:31.760 --> 01:37.910
But you want to just follow this convention use plural because that's what a table describes is multiple

01:37.910 --> 01:43.390
cats or people instead of person or payments instead of payment and so on.

01:43.870 --> 01:44.410
OK.

01:44.570 --> 01:51.440
So we have parentheses and then we list our columns and the corresponding data types so name will be

01:51.710 --> 01:58.800
Vardar with a 100 character limit comma age will be an integer.

01:58.850 --> 02:01.990
So let's hop over to call 9 and see if it works.

02:02.330 --> 02:05.210
So the first thing I'll do is just make a new database.

02:05.210 --> 02:07.160
You don't have to do this if you're following along.

02:07.160 --> 02:12.340
But I'll just call one cat app.

02:12.550 --> 02:13.930
Forgot my semi-colon.

02:14.350 --> 02:19.930
Then we will use.

02:19.940 --> 02:30.220
OK so now the next thing we'll do is create table cat and then we can either do parentheses here and

02:30.220 --> 02:32.720
that's what I usually do when I'm working in the mines.

02:32.710 --> 02:36.070
Q. Well command line or in the shell.

02:36.340 --> 02:38.110
So you don't have to worry about spaces too much.

02:38.320 --> 02:50.100
So create table cats and then we'll say name is var char 100 comma age isn't it.

02:50.350 --> 02:52.690
And then we'll close our parentheses with a semi-colon.

02:53.640 --> 02:54.690
Queery OK.

02:54.780 --> 02:57.910
0 rows effected perfect.

02:57.990 --> 03:01.710
It appears to have worked or at least we have to trust that it works because right now we don't have

03:01.710 --> 03:03.230
a way of testing that.

03:03.570 --> 03:06.350
But we will the next video cliffhanger.
