1 00:00:00,120 --> 00:00:04,970 Next, I'm going to show a couple of quick utility commands we can use to inspect our tables. 2 00:00:04,980 --> 00:00:11,610 So if we created a table and we're not using one of these graphical tools, how do we know from within 3 00:00:11,610 --> 00:00:14,900 MySQL, from within the command line that it worked? 4 00:00:14,910 --> 00:00:17,730 Well, the first thing we can do is just look at the tables. 5 00:00:17,730 --> 00:00:21,240 What tables exist using the show tables command. 6 00:00:21,240 --> 00:00:24,510 So this is going to show the tables from our current database. 7 00:00:24,510 --> 00:00:27,480 And remember, I had to use a database. 8 00:00:27,480 --> 00:00:28,290 I'm connected. 9 00:00:28,290 --> 00:00:33,840 I'm inside of one database, which is Pet Shop, and there's two tables in there. 10 00:00:33,840 --> 00:00:40,380 But if I switch to some other database, like I think I have a T shop and if I try show tables, there's 11 00:00:40,380 --> 00:00:41,400 nothing here. 12 00:00:41,580 --> 00:00:45,690 So we have these different silos of information, silos of tables. 13 00:00:45,690 --> 00:00:47,760 That's the whole point of separate databases. 14 00:00:47,760 --> 00:00:50,130 So let me go back to pet shop. 15 00:00:51,360 --> 00:00:52,050 All right. 16 00:00:52,050 --> 00:00:53,310 And then show tables. 17 00:00:53,310 --> 00:00:54,930 We've got cats and dogs. 18 00:00:55,170 --> 00:00:57,690 But what if I want to know more about the tables? 19 00:00:57,720 --> 00:00:59,480 Are they correctly formed? 20 00:00:59,490 --> 00:01:00,810 What are the column names? 21 00:01:00,900 --> 00:01:06,150 I can use a command called Show Columns from and then the name of a table. 22 00:01:06,150 --> 00:01:10,290 So show columns from cats. 23 00:01:10,920 --> 00:01:12,000 And there we go. 24 00:01:12,030 --> 00:01:15,510 There's some extra information over here we're going to learn about very soon. 25 00:01:15,510 --> 00:01:17,460 NULL and key and default. 26 00:01:17,460 --> 00:01:20,340 But you'll see we have the name of the field. 27 00:01:20,340 --> 00:01:21,450 It's just called field. 28 00:01:21,450 --> 00:01:23,160 So name or age. 29 00:01:23,160 --> 00:01:26,850 And then there type var car 50 integer. 30 00:01:27,300 --> 00:01:29,820 Same thing if I do show columns from dogs. 31 00:01:31,510 --> 00:01:32,110 Name it. 32 00:01:32,120 --> 00:01:33,280 Savarkar 52. 33 00:01:33,280 --> 00:01:34,300 Savarkar 50. 34 00:01:34,330 --> 00:01:35,590 Age is an integer. 35 00:01:37,240 --> 00:01:44,120 Now, there's actually another even shorter version, which is DSC for describe table name. 36 00:01:44,140 --> 00:01:47,950 So I believe you can actually just do describe cats. 37 00:01:48,680 --> 00:01:51,380 But that's way too long for all of us, of course. 38 00:01:51,380 --> 00:01:58,580 So we can do desk or describe DSC, and that's going to give us the same output we've already seen. 39 00:01:58,910 --> 00:02:05,120 Now, if you are trying to work mostly within one of these graphical tools, we don't have to run those 40 00:02:05,120 --> 00:02:05,540 commands. 41 00:02:05,540 --> 00:02:11,990 I mean, I can here I am in workbench if I make sure that I'm working inside of the pet Shop database, 42 00:02:12,920 --> 00:02:20,600 I can then do something like describe dogs and then execute that and we see our result here. 43 00:02:20,630 --> 00:02:21,800 It says name. 44 00:02:21,800 --> 00:02:24,920 It's var 53 to Savarkar 58 just for our car. 45 00:02:24,920 --> 00:02:27,890 50 G's age is an integer rather. 46 00:02:28,040 --> 00:02:34,310 I can do that, but I have an easier way if I just look at one of the tables like cats right here, 47 00:02:34,460 --> 00:02:37,040 way in this corner, it's hard to read. 48 00:02:37,040 --> 00:02:39,860 And once again, this app doesn't let me zoom in. 49 00:02:39,860 --> 00:02:40,670 You'll see. 50 00:02:40,670 --> 00:02:42,110 It's showing me the columns. 51 00:02:42,110 --> 00:02:48,350 Name is var card 50 Age is an integer, so I don't really have to run a command to get that information 52 00:02:48,350 --> 00:02:50,090 like I do from the command line. 53 00:02:50,480 --> 00:02:52,850 Same thing over here in DB gate. 54 00:02:52,850 --> 00:02:59,180 If I look at the tables for pet Shop, so whatever database I have selected, it will show me the structure. 55 00:02:59,300 --> 00:03:00,980 So this is an empty database. 56 00:03:00,980 --> 00:03:03,350 There's no tables, but Pet Shop has to. 57 00:03:03,380 --> 00:03:04,760 Let's look at dogs. 58 00:03:05,030 --> 00:03:06,080 Look at how nice that is. 59 00:03:06,080 --> 00:03:11,180 It says name is bar car 50, Breed is very car 50 ages and it's showing me the columns. 60 00:03:11,180 --> 00:03:12,470 I don't have to do anything. 61 00:03:12,560 --> 00:03:16,400 But I could also ask for those columns if I wanted to. 62 00:03:17,090 --> 00:03:24,080 By the way, right here I just commented SQL out in and out, meaning it's inactive, it's still here, 63 00:03:24,080 --> 00:03:26,540 but this code won't do anything if I run the script. 64 00:03:26,540 --> 00:03:28,430 So that's a SQL comment. 65 00:03:28,430 --> 00:03:33,890 I'll have a separate video on that just to make it clear, but two dashes will make any line of SQL 66 00:03:33,920 --> 00:03:34,490 null. 67 00:03:34,640 --> 00:03:36,320 Basically do nothing. 68 00:03:36,320 --> 00:03:38,180 It comments it out, it preserves it. 69 00:03:38,180 --> 00:03:45,080 So we still have a record of it and I can toggle that on and off on my Mac using command forward slash. 70 00:03:45,230 --> 00:03:48,740 But if I run this right now, we shut this down a bit. 71 00:03:48,860 --> 00:03:50,300 Executes well. 72 00:03:50,300 --> 00:03:52,760 Nothing happens because there is no SQL here. 73 00:03:52,880 --> 00:03:55,370 In the eyes of my SQL, this was empty. 74 00:03:55,820 --> 00:04:01,820 So what I was going to show though is I can describe cats, for example, but it's kind of silly if 75 00:04:01,820 --> 00:04:03,860 I'm using one of these graphical user interfaces. 76 00:04:03,860 --> 00:04:05,450 If I open up my results pane. 77 00:04:05,450 --> 00:04:06,140 Here it is. 78 00:04:06,140 --> 00:04:11,900 Name var 50 age int but I could see that easily if I just look at cats visually. 79 00:04:12,380 --> 00:04:12,640 Okay. 80 00:04:12,830 --> 00:04:17,930 So that's a long winded way of saying there's many ways to check your work to see if our table was created 81 00:04:17,930 --> 00:04:21,170 successfully, to see what the columns and data types are. 82 00:04:21,200 --> 00:04:26,000 You can do this long version or just nice describe or even nicer. 83 00:04:26,000 --> 00:04:32,360 If you're using a graphical interface, don't do any commands and just look at the results or the table 84 00:04:32,360 --> 00:04:33,500 view that it shows you.