1 00:00:00,180 --> 00:00:00,600 All right. 2 00:00:00,600 --> 00:00:04,650 It's time for you to get a little bit of practice with what we've learned in the past few videos. 3 00:00:04,650 --> 00:00:08,250 I'd like you to make a table and insert some values into that table. 4 00:00:08,370 --> 00:00:11,910 According to these instructions, create a table called people. 5 00:00:12,120 --> 00:00:13,800 It should have three columns. 6 00:00:13,800 --> 00:00:16,500 First name is a piece of text or a string. 7 00:00:16,500 --> 00:00:20,070 20 characters or fewer last name, same thing. 8 00:00:20,070 --> 00:00:21,900 And age is a number. 9 00:00:22,380 --> 00:00:24,840 It's I guess we all know age is on the number. 10 00:00:25,200 --> 00:00:25,890 Very funny. 11 00:00:25,890 --> 00:00:28,020 Really, though age is just an integer here. 12 00:00:28,560 --> 00:00:32,670 Once you've done that, I'd like you to insert your first person you can. 13 00:00:32,700 --> 00:00:37,800 You don't have to follow these exact names if you don't want to type them out, but I'd like you to 14 00:00:37,800 --> 00:00:45,810 insert this person, Tina Belcher, who's 13, Bob Belcher is 42, and then do a multiple insert and 15 00:00:45,810 --> 00:00:48,360 get these three all in one go. 16 00:00:48,690 --> 00:00:51,240 And then you can just delete the whole table if you want. 17 00:00:51,240 --> 00:00:52,230 That's what I'm going to do. 18 00:00:52,230 --> 00:00:54,450 So I'm not going to bother making a new database. 19 00:00:54,450 --> 00:00:59,100 I'm just going to do it right here instead of my what is this pet pet shop? 20 00:00:59,100 --> 00:00:59,760 Sure. 21 00:01:00,150 --> 00:01:02,160 We're also selling humans for a pet shop. 22 00:01:02,670 --> 00:01:05,220 So go ahead and try this and pause. 23 00:01:05,220 --> 00:01:10,230 Please pause, because I'm about to go over the solution and I hope you try it on your own first. 24 00:01:10,230 --> 00:01:10,980 So here we go. 25 00:01:11,160 --> 00:01:15,480 We're going to create a people table first name, last name and age. 26 00:01:15,930 --> 00:01:17,670 I guess I'll do this from the shell. 27 00:01:17,670 --> 00:01:20,700 So create table, people. 28 00:01:20,730 --> 00:01:21,570 All right. 29 00:01:21,930 --> 00:01:27,150 And then we want let's do a couple of spaces just to format it fancy. 30 00:01:27,150 --> 00:01:35,340 We'll do first underscore name is a var car var char 20 and then last underscore name is the same thing. 31 00:01:35,340 --> 00:01:41,670 Var car 20 and then age is an int. 32 00:01:42,300 --> 00:01:46,200 I'll close my friends, close the semi or add the semicolon. 33 00:01:46,200 --> 00:01:47,130 That looks good. 34 00:01:47,130 --> 00:01:53,010 Let's double check, describe raffle, describe people and that's good. 35 00:01:53,010 --> 00:01:55,800 First name var car last name var car age int. 36 00:01:56,250 --> 00:01:57,930 Now let's insert this first person. 37 00:01:57,930 --> 00:02:06,420 Tina belcher is 13 so we'll do insert into people and the order is just up to us. 38 00:02:06,420 --> 00:02:12,090 But let's say first name, last name, age and then values. 39 00:02:12,090 --> 00:02:14,040 We'll have Tina. 40 00:02:15,710 --> 00:02:16,670 Voucher. 41 00:02:17,900 --> 00:02:18,830 13. 42 00:02:20,760 --> 00:02:25,470 And let's verify Select star from people looks good. 43 00:02:25,500 --> 00:02:26,970 Tina Belcher 13. 44 00:02:26,970 --> 00:02:28,410 First name, Last name, Age. 45 00:02:28,710 --> 00:02:29,430 All right. 46 00:02:29,430 --> 00:02:31,560 So next up, we've got a second person. 47 00:02:31,560 --> 00:02:33,660 Bob Belcher is 42. 48 00:02:33,810 --> 00:02:36,000 So I'll do it again from the command line. 49 00:02:36,600 --> 00:02:42,360 Of course, you can do these from anywhere that you can run a MySQL query, but I'll do an insert, 50 00:02:43,140 --> 00:02:43,800 honestly. 51 00:02:43,800 --> 00:02:46,380 Well, sure, I'll just retype the whole thing. 52 00:02:46,380 --> 00:02:52,140 But I was going to say, I can just recall this line and I might save myself some time, but it's all 53 00:02:52,140 --> 00:02:52,590 right. 54 00:02:52,590 --> 00:02:54,120 We'll do it insert into. 55 00:02:55,390 --> 00:03:02,710 People first underscore name, last, underscore, name and age values. 56 00:03:03,220 --> 00:03:05,080 And then we have Bob. 57 00:03:06,540 --> 00:03:07,410 Belcher. 58 00:03:08,200 --> 00:03:09,400 42. 59 00:03:11,030 --> 00:03:15,140 Select staff from people, and we see both of them. 60 00:03:15,230 --> 00:03:15,980 Great. 61 00:03:15,980 --> 00:03:21,980 So the last thing we'll do is our multi insert and I think I'll do this one from a file just to make 62 00:03:21,980 --> 00:03:23,030 it easier to type. 63 00:03:23,210 --> 00:03:29,930 So we've got Linda Belcher 45 and I'll speed this up so you don't have to watch me type the whole thing, 64 00:03:29,930 --> 00:03:31,810 but let's type the query select. 65 00:03:31,820 --> 00:03:42,020 Why do I keep saying select insert into people and let's do first name again, last name, age and then 66 00:03:42,020 --> 00:03:42,980 our values. 67 00:03:42,980 --> 00:03:48,020 Now I am going to have to refresh over here in the workbench. 68 00:03:48,530 --> 00:03:52,220 So I see my people table show up. 69 00:03:52,220 --> 00:03:52,790 There it is. 70 00:03:52,790 --> 00:03:57,890 Okay, so we're working with Pet Shop, which has a people table, and the first person we're inserting 71 00:03:57,890 --> 00:04:00,020 is, Is it Linda Belcher? 72 00:04:00,020 --> 00:04:02,510 I think I don't remember her age. 73 00:04:02,750 --> 00:04:05,420 She is supposed to be 45. 74 00:04:07,170 --> 00:04:07,850 Okay. 75 00:04:08,190 --> 00:04:14,370 And then the next person had a comma in there, Phillip Frond, who is 38. 76 00:04:15,560 --> 00:04:17,029 38. 77 00:04:17,779 --> 00:04:21,079 And then we have one more person, which is Calvin. 78 00:04:23,000 --> 00:04:26,060 And I don't know how you spell fish or fish. 79 00:04:26,060 --> 00:04:26,330 C. 80 00:04:26,330 --> 00:04:27,020 H. 81 00:04:27,440 --> 00:04:28,130 O. 82 00:04:28,160 --> 00:04:28,820 E. 83 00:04:28,850 --> 00:04:29,110 D. 84 00:04:29,150 --> 00:04:29,330 E. 85 00:04:29,330 --> 00:04:29,810 R. 86 00:04:31,390 --> 00:04:32,810 Who is 70? 87 00:04:32,830 --> 00:04:33,560 Is that what I said? 88 00:04:33,580 --> 00:04:34,360 All right. 89 00:04:34,810 --> 00:04:35,650 Close enough. 90 00:04:35,650 --> 00:04:38,470 And if I really want it to be particular, I can line these up. 91 00:04:38,470 --> 00:04:39,910 It doesn't matter at all. 92 00:04:39,940 --> 00:04:41,500 Put my semicolon in there. 93 00:04:41,530 --> 00:04:42,730 Execute the query. 94 00:04:43,580 --> 00:04:45,470 And do we know if it worked? 95 00:04:45,500 --> 00:04:49,150 Well, we don't get an error message to get a check mark, which is good. 96 00:04:49,160 --> 00:04:50,900 It says three rows affected. 97 00:04:50,930 --> 00:04:52,100 That's also good. 98 00:04:52,100 --> 00:04:56,060 But I can do a select star from people. 99 00:04:56,450 --> 00:05:01,310 And now we see our three additions that we made in one go with one insert. 100 00:05:01,490 --> 00:05:06,350 And then the last thing I was going to do, which is not really in the instructions, is drop people, 101 00:05:06,380 --> 00:05:08,880 drop table people. 102 00:05:08,900 --> 00:05:09,740 Goodbye. 103 00:05:10,010 --> 00:05:11,870 And all of our people are gone. 104 00:05:11,870 --> 00:05:14,060 If I try and select Star, nothing happened. 105 00:05:14,090 --> 00:05:15,620 Well, it's not that nothing happened. 106 00:05:15,620 --> 00:05:20,810 We get an error because there are no people or rather there is no people table. 107 00:05:21,800 --> 00:05:23,180 So that's our little exercise. 108 00:05:23,210 --> 00:05:25,100 Next up, we've got more to learn. 109 00:05:25,430 --> 00:05:27,050 Obviously, a lot left.