Page 1 of 1

easy mysql question

Posted: Thu Jan 11, 2007 4:01 pm
by boo_lolly
i have a database table, one of the columns is set to CHAR(20)... how do i change it to CHAR(30) using the mysql command line?

Posted: Thu Jan 11, 2007 4:08 pm
by Obadiah
try this

Code: Select all

ALTER TABLE `table_name` CHANGE `field_name` `field_name` INT( 30 ) NOT NULL AUTO_INCREMENT 

Posted: Thu Jan 11, 2007 4:13 pm
by boo_lolly
thanks obadiah! what is the purpose of AUTO_INCREMENT? what would the effect be if i didn't place that in the command?

Posted: Thu Jan 11, 2007 4:15 pm
by Obadiah
sorry...i tested it on one of my databases first the field i tested it on had an auto increment...did you add the autoincrement to it as well...ill help you remove it if so

Code: Select all

ALTER TABLE `table_name` CHANGE `field_name` `field_name` VARCHAR( 30 )
would work just fine