Rename a column in MySQL

Posted in July 2012 by under sysadmin

It is easy to rename a column in MySQL.

To change the column name of a varchar(255) field from carmaker to manufacturer in the cars table

ALTER TABLE cars CHANGE carmaker manufacturer varchar(255);

More generally

ALTER TABLE tablename CHANGE oldname newname datatype;

More information can be found in the MySQL manual.