Next up, I'd like to show you my SQL comments.
Now, this is a piece of syntax that technically you could use if you were working in the command line,
but it doesn't really have any benefit.
Most of the time you'll see this is in a file.
So when I say comment, this is a concept that is pretty ubiquitous across all programming languages.
The idea is that I can have some notes in my code.
I can have pieces of code that I don't actually have execute without deleting from my file.
An example would be, let's say I have some piece of syntax like show tables.
Obviously that is my SQL.
We know that it works, but then I want to annotate it up top and say to list all tables in DB.
Well, if I tried to run this file, this is not valid SQL code.
We're going to have a bad time and I could run it in the terminal.
And you see, I get an error.
I try running it over here.
I'll also get an error.
It might be hard to show you.
There it is.
See that red right there?
That is an error.
So to avoid this, if I want to have a note or some piece of code that I turn off, I can use two dashes
and then a space.
I do have to have a space.
Afterwards, you'll see that the editor editor changes color here or I guess it doesn't change color,
does it?
It changes the font weight.
It's not bolded anymore like it is here.
So now if I ran this, we don't get an error.
It actually just runs this code and this is completely ignored.
But it's still there.
It's not deleted, it's just ignored.
Same thing.
If I did it for this line, I don't want this code to run right now, but I want some other stuff to
run.
Well, I can leave it in there with two dashes, assuming that it makes sense to leave it in there.
So you can use this yourself to make notes in your SQL files within the workbench.
I mean, technically you can do it over here in the command line.
I can do like show tables.
If I put those two dashes in front, it doesn't run.
I do the same line without those two dashes and it does run.
But most of the time you're going to do it in a file.
You'll see it in some of my solution code.
One common situation it might come up is if I have some code, which we haven't seen this as this later
in the course, but some code from the future.
And I want to leave it in here, but I want to do some other stuff down here.
I don't want to delete it, but I don't want it to run again because this is making a table.
I don't want to be making a table over and over.
I can highlight this and instead of having to do a hyphen here and then another one here or a comment
rather, I can highlight it in the workbench and then use the shortcut command forward slash on a mac.
I believe it's control forward slash on a PC and then I can undo that again, toggling it with this
same shortcut so that can be nice and you'll see me do that at some points in the course just so that
I can have some code, have a record of it, but not have it run every time I run this file.
Okay, that is it for comments to dashes.
I think the dashes, are they hyphens?
I think hyphen is longer in.
I don't know.
Anyway, those two characters and then a space.
Don't forget the space will make SQL.
Ignore your code.