Next up, a quick little concept.
We're going to talk about aliases.
When we print out or when we select data, we're not always printing it out, but when we're selecting
data, we can rename a column to make it shorter or easier to understand.
So it's not the same as renaming the column forever.
It's just in our output result.
For example, maybe I don't like working with Kat ID, it's kind of a stupid name.
I should just call it ID.
Well, I can simplify my results by renaming or giving an alias to that column using the as keyword.
Again, this is temporary only for this query and my results would look like this ID instead of cat
ID.
So let me show you.
Let's do a select cat ID and name from cats.
There we are.
Cat underscore ID.
You can see it technically is case insensitive because it should be lowercase.
That's the way the column is named.
But my SQL didn't care anyway.
Cat id in name.
I don't like cat ID, it's just too long.
I need to shorten it so I can rename it.
If right after the name of that column I'm selecting, I put as and then some other name we have ID,
but again, if I describe Cat, it's still called Cat ID.
If I select everything, let's just select star from cats.
It's still called Cat ID.
It was just a temporary thing.
So let's do one more example.
Let's do name as.
Kiddie name.
Sure.
From cats.
And our output has the column name, kiddie name.
But of course, the values here are from the original name column.
So this isn't just about renaming a column when you print it out.
When we get into fancier things like joining data together or writing fancy select queries that are
really complicated, we might have some resulting data that doesn't really have a name.
We use the as keyword to give it a meaningful name.
But for now, the way I've introduced it is in a pretty limited use case.
We would rename a column to make it shorter or easier to understand, but it doesn't help us that much
yet.