views:

39

answers:

3

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).

+1  A: 

I think what you mean is:

alter table obj_details modify IMG_SRC varchar(180);
Francisco Soto
Still got the same error with that one.
Ankur
+1  A: 

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.)

Dominic Rodger
+1  A: 

You're missing MODIFY COLUMN, and you're specifying IMG_SRC twice for some reason.

Try this instead,

ALTER TABLE `obj_details` MODIFY COLUMN `IMG_SRC` VARCHAR(180);
Rich Adams