Reputation: 3549
I am writing a database script to change the maximum number of characters allowed on an existing column.
I want this column to be able to hold more characters, without deleting it.
How would I write the MySQL query for doing something like this?
Upvotes: 0
Views: 4253
Reputation: 25862
you can just use MODIFY to increase it
ALTER TABLE mytable MODIFY mycolumn VARCHAR(999)
you can also use CHANGE instead of MODIFY, but CHANGE will also rename the column so you would either have to provide a new column name or just repeat it a second time
ALTER TABLE mytable CHANGE mycolumn mynewcolumn VARCHAR(999)
if you note in the second fiddle you will see that the column name is changed and each time i alter the table im inserting characters greater than the allotted number originally set.
Upvotes: 4