I have a table called sidebar_items
and it has a Type
column, which is of type enum('image', 'html')
. I would like to change this column to be of type enum('image', 'html', 'structure')
. I have tried this:
alter table sidebar_items modify Type Type enum('image', 'html', 'structure');
It gives me the error of
alter table sidebar_items modify Type Type enum('image', 'html', 'structure') Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Type enum('image', 'html', 'structure')' at line 1
I have tried with `Type` as well. Can I make this query work?
Alternatively, I can resolve the problem by:
- creating a
temp
table with the same structure assidebar_items
- migrating the records from
sidebar_items
to thetemp
table - dropping
sidebar_items
- recreating
sidebar_items
with the new type forType
- migrating the records from the
temp
table tosidebar_items
- dropping the
temp
table
However, I am interested to know whether there are any simpler solutions, possibly with a single alter table
command.