Mysql change column details

Ankur picture Ankur · May 14, 2010 · Viewed 9.9k times · Source

I am trying to redefine the number of varchars a column can have (in a MySQL db).

I am doing

alter table obj_details IMG_SRC IMG_SRC varchar(180);

I want to change the number of characters that can be used in the column IMG_SRC to 180 (it is currently 100). But I get an error saying that I should check the syntax near IMG_SRC IMG_SRC varchar(180).

Answer

Dominic Rodger picture Dominic Rodger · May 14, 2010

Why did you write IMG_SRC twice? You want:

ALTER TABLE obj_details MODIFY IMG_SRC varchar(180);

(For what it's worth the COLUMN in MODIFY COLUMN is optional, see here.)