Next, I'm going to show a couple of quick utility commands we can use to inspect our tables.
So if we created a table and we're not using one of these graphical tools, how do we know from within
MySQL, from within the command line that it worked?
Well, the first thing we can do is just look at the tables.
What tables exist using the show tables command.
So this is going to show the tables from our current database.
And remember, I had to use a database.
I'm connected.
I'm inside of one database, which is Pet Shop, and there's two tables in there.
But if I switch to some other database, like I think I have a T shop and if I try show tables, there's
nothing here.
So we have these different silos of information, silos of tables.
That's the whole point of separate databases.
So let me go back to pet shop.
All right.
And then show tables.
We've got cats and dogs.
But what if I want to know more about the tables?
Are they correctly formed?
What are the column names?
I can use a command called Show Columns from and then the name of a table.
So show columns from cats.
And there we go.
There's some extra information over here we're going to learn about very soon.
NULL and key and default.
But you'll see we have the name of the field.
It's just called field.
So name or age.
And then there type var car 50 integer.
Same thing if I do show columns from dogs.
Name it.
Savarkar 52.
Savarkar 50.
Age is an integer.
Now, there's actually another even shorter version, which is DSC for describe table name.
So I believe you can actually just do describe cats.
But that's way too long for all of us, of course.
So we can do desk or describe DSC, and that's going to give us the same output we've already seen.
Now, if you are trying to work mostly within one of these graphical tools, we don't have to run those
commands.
I mean, I can here I am in workbench if I make sure that I'm working inside of the pet Shop database,
I can then do something like describe dogs and then execute that and we see our result here.
It says name.
It's var 53 to Savarkar 58 just for our car.
50 G's age is an integer rather.
I can do that, but I have an easier way if I just look at one of the tables like cats right here,
way in this corner, it's hard to read.
And once again, this app doesn't let me zoom in.
You'll see.
It's showing me the columns.
Name is var card 50 Age is an integer, so I don't really have to run a command to get that information
like I do from the command line.
Same thing over here in DB gate.
If I look at the tables for pet Shop, so whatever database I have selected, it will show me the structure.
So this is an empty database.
There's no tables, but Pet Shop has to.
Let's look at dogs.
Look at how nice that is.
It says name is bar car 50, Breed is very car 50 ages and it's showing me the columns.
I don't have to do anything.
But I could also ask for those columns if I wanted to.
By the way, right here I just commented SQL out in and out, meaning it's inactive, it's still here,
but this code won't do anything if I run the script.
So that's a SQL comment.
I'll have a separate video on that just to make it clear, but two dashes will make any line of SQL
null.
Basically do nothing.
It comments it out, it preserves it.
So we still have a record of it and I can toggle that on and off on my Mac using command forward slash.
But if I run this right now, we shut this down a bit.
Executes well.
Nothing happens because there is no SQL here.
In the eyes of my SQL, this was empty.
So what I was going to show though is I can describe cats, for example, but it's kind of silly if
I'm using one of these graphical user interfaces.
If I open up my results pane.
Here it is.
Name var 50 age int but I could see that easily if I just look at cats visually.
Okay.
So that's a long winded way of saying there's many ways to check your work to see if our table was created
successfully, to see what the columns and data types are.
You can do this long version or just nice describe or even nicer.
If you're using a graphical interface, don't do any commands and just look at the results or the table
view that it shows you.