Reputation: 5687
Altering a table column using change
is not working but using modify
the same query statement works fine.
With change it fails:
alter table users change name varchar(100);
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 'varchar(100)' at line 1 0.000 sec
With Modify it works.
alter table users modify name varchar(100);
Upvotes: 1
Views: 128
Reputation: 312219
The syntax for CHANGE
is different than MODIFY
.
From the documentation:
CHANGE [COLUMN] old_col_name new_col_name column_definition
So, in your case, you should use:
alter table users change name name varchar(100);
Upvotes: 1
Reputation: 3386
If you use CHANGE
then you have to specify a new name for the column, so the following should work:
alter table users change name newname varchar(100);
Look at the alter specification for CHANGE
: http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
Upvotes: 1