The next thing we'll see is how we can modify existing columns, not their name, but modify the actual
column definition.
So in this example, I'm altering the table suppliers to modify the biz name column so that it is a
var car 100, whatever it was before it is now a var car 100.
Now we have to be somewhat careful with this, of course, because if you had a numeric column that
you were turning into text or text, you're turning into numeric or a date column, you're suddenly
turning into an int that could cause a lot of issues.
You want to you want to be very conscious of that.
But I'm just going to show you a simple example.
Let's say that I realized I wanted something to be not null and it was currently knowable and I want
to make it a var car with a larger size.
So we've got I don't know, let's go back to companies.
We have var car 255 for name.
Let's actually shrink that down.
Sure.
So I renamed that column to company name, if you remember.
Here, let's do describe companies.
Here we are.
We see that company name is var two, five, five.
So let's say maybe I want to add a default value.
And I also want to make it a var card 100.
We're enforcing a shorter limit for our var cards.
This is stupid, but let's just do it.
So I'll do an alter table companies if that's still the name, of course.
And then modify.
And what am I trying to modify?
The company name column.
Whoops.
This way.
Company name.
And now I can say I want it to be a var char.
Uh, 100 and then give it a default value of a name.
Unknown Something like that.
If you put a company in here, we don't know the name, then its default will be unknown.
So right now it's var 255.
Oh no.
I have these quotes there that might cause me trouble.
Let's try that again.
All right, I run it.
Let's describe.
Where are you companies?
It's still called company name, but now var 100 is the type.
And we see that default is set to unknown.
And if I were just to quickly insert into companies, we have company name and address values.
Let's insert no company name.
So I'm going to leave that off.
That was the whole point I wanted to show.
So let's only insert the address and address will be two five, five, four Rose Lane.
And if I now select star from my companies, we see the default for company name kicked in, which is
unknown, and that's what we get instead of null.
All right.
So that's how you can modify a column by changing its type.
There's also a second option.
If you wanted to rename a column and change its definition, you can use change.
So I use this less often because a lot of the time I might just want to modify an existing column,
not rename it.
But if you use change, you have to say the current column name, then the new column name and then
the new column definition.
So this is saying take the supplier's table, change the business column, rename it to biz name, and
set the definition to be a var of 50.
So I don't think I need to show an example of that.
It's the same concept, right?
We just have to say old name, new name definition.
Whereas when we modify, we don't have the opportunity to change the name of a column.
But it's simpler.
We only say, Here's the current name and the new definition for that current named column OC.