1 00:00:00,090 --> 00:00:05,730 So we can create these tables that are completely empty waiting for us to put data inside of them. 2 00:00:05,760 --> 00:00:07,620 Now, let's talk about how we do that. 3 00:00:07,620 --> 00:00:09,180 How do we insert data? 4 00:00:09,210 --> 00:00:12,830 Well, the answer is we use an insert statement. 5 00:00:12,840 --> 00:00:13,980 It looks like this. 6 00:00:13,980 --> 00:00:18,390 We use the keyword insert and then into a table name. 7 00:00:18,390 --> 00:00:22,590 So for inserting into the cat's table, insert into cats. 8 00:00:22,800 --> 00:00:29,550 And then we have parentheses and we specify the columns that we are inserting and in what order the 9 00:00:29,550 --> 00:00:31,140 data will be expected. 10 00:00:31,290 --> 00:00:37,020 So in other words, I'm going to say name, it's going to be first and then H and then down here, which 11 00:00:37,020 --> 00:00:38,550 does not have to be on a second line. 12 00:00:38,550 --> 00:00:40,830 It's just to fit it into the slides nicely. 13 00:00:40,830 --> 00:00:44,250 We write values and then we have to follow that pattern. 14 00:00:44,250 --> 00:00:48,450 Name is right there, Jetson H comes afterwards seven. 15 00:00:48,450 --> 00:00:50,370 So we put them both in parentheses. 16 00:00:50,370 --> 00:00:56,250 So this is a pair, in this case a pair of columns and then a pair of corresponding values. 17 00:00:56,250 --> 00:00:58,200 So here are some other ways of writing this. 18 00:00:58,200 --> 00:01:01,500 Just so you are aware, you can do it in one line. 19 00:01:01,500 --> 00:01:07,380 You'll even see people space it out in some weird ways like this, it doesn't matter as long as there's 20 00:01:07,380 --> 00:01:08,550 a semicolon at the end. 21 00:01:08,550 --> 00:01:12,390 My SQL knows where the end of the entire statement is. 22 00:01:12,600 --> 00:01:18,270 What really matters, though, is making sure you have the correct table name spelled correctly and 23 00:01:18,270 --> 00:01:22,470 that you pay attention to the order that you list the different values in. 24 00:01:22,920 --> 00:01:27,420 So I'm going to first insert from the command line. 25 00:01:27,420 --> 00:01:30,330 So let's see what database I'm working in. 26 00:01:31,410 --> 00:01:32,610 Okay, we're in the pet shop. 27 00:01:32,610 --> 00:01:33,240 Fine. 28 00:01:33,240 --> 00:01:36,030 Let's look at my cat table. 29 00:01:36,390 --> 00:01:38,580 And I think I dropped that table, didn't I? 30 00:01:38,610 --> 00:01:41,790 So I think I'm going to have to remake that table. 31 00:01:41,790 --> 00:01:48,300 So let's do create table cats, which will have very simple stuff. 32 00:01:48,330 --> 00:01:51,210 It's going to have name again is a var char. 33 00:01:51,240 --> 00:01:54,720 This is basically recap from previous videos. 34 00:01:54,720 --> 00:01:57,390 Age will be an int and that should be it. 35 00:01:58,080 --> 00:01:59,700 So let's describe cats now. 36 00:02:00,120 --> 00:02:00,690 There we go. 37 00:02:00,690 --> 00:02:03,060 Name an age, let's insert a cat. 38 00:02:03,060 --> 00:02:09,180 So insert into cats and then what am I going to insert into cats? 39 00:02:09,180 --> 00:02:10,860 Well, first I'll give you the name. 40 00:02:10,860 --> 00:02:17,670 Second, I'll give you the age and then I can hit enter if I want, just to work on a second line values. 41 00:02:17,670 --> 00:02:20,190 And then I have to have name and then age. 42 00:02:20,490 --> 00:02:22,440 So what should that name be? 43 00:02:22,800 --> 00:02:25,680 Let's insert one of my cats that I have at home. 44 00:02:25,680 --> 00:02:32,820 I've got a cat named Blue Steel and I don't know her age, honestly, she's like five or six at this 45 00:02:32,820 --> 00:02:33,390 point. 46 00:02:33,390 --> 00:02:38,550 So let's just leave it at that hit enter with my semicolon. 47 00:02:38,550 --> 00:02:40,770 And I think it worked right. 48 00:02:40,770 --> 00:02:42,570 It says one row affected query. 49 00:02:42,570 --> 00:02:43,320 Okay. 50 00:02:43,320 --> 00:02:45,510 In the next video, we'll learn how to check our work. 51 00:02:45,510 --> 00:02:48,750 But let's insert one more row into our table. 52 00:02:48,750 --> 00:02:53,490 But this time I'm going to do it over in one of my graphical interfaces. 53 00:02:53,490 --> 00:02:56,820 So let's do it here in DB gates. 54 00:02:56,820 --> 00:03:03,180 Although the process will be almost identical if you are working within what you call a SQL Workbench 55 00:03:03,180 --> 00:03:04,290 MySQL Workbench. 56 00:03:04,290 --> 00:03:08,040 So all I'm going to do is make sure I'm working in the pet Shop database. 57 00:03:08,040 --> 00:03:09,780 We can see there's a cat's table there. 58 00:03:10,200 --> 00:03:20,550 I'll comment this out and I'll just write Insert into cat and then name and then age values and let's 59 00:03:20,550 --> 00:03:22,410 insert a different cat. 60 00:03:22,410 --> 00:03:29,730 How about, I don't know, Jenkins, the cat who is seven years old. 61 00:03:29,970 --> 00:03:33,570 So I'll run this entire file. 62 00:03:33,660 --> 00:03:34,590 Execute it. 63 00:03:35,630 --> 00:03:39,320 And we get a response back and it just says, Yeah, that worked. 64 00:03:39,350 --> 00:03:39,980 Okay. 65 00:03:40,010 --> 00:03:41,300 So we trust that it worked. 66 00:03:41,300 --> 00:03:44,840 Until the next video, we'll take a look and make sure our values are in there.