How to change the type of a column from varchar(30) to varcahar(100)?

Mikey picture Mikey · May 26, 2011 · Viewed 21.2k times · Source

I have a table that describes like this:

mysql> describe easy_table;
+---------------------+--------------+------+-----+---------+----------------+
| Field               | Type         | Null | Key | Default | Extra          |
+---------------------+--------------+------+-----+---------+----------------+
| id                  | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| version             | bigint(20)   | NO   |     | NULL    |                |
| account_id          | bigint(20)   | NO   | MUL | NULL    |                |
| city                | varchar(30)  | NO   |     | NULL    |                |
...
| name                | varchar(255) | YES  |     | NULL    |                |
| name_two            | varchar(255) | YES  |     | NULL    |                |
+---------------------+--------------+------+-----+---------+----------------+
13 rows in set (0.03 sec)

I'm trying to make the city varchar bigger to varchar(100) and this line doesn't work

alter table easy_table alter column city varchar(100);

this also doesn't work

alter table easy_table alter column city varchar(100) not null;

I get this error:

ERROR 1064 (42000): 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

Answer

ajreal picture ajreal · May 26, 2011
alter table easy_table modify column city varchar(100) not null;