MySQL Alter Table Change Column Type

The RazorSQL alter table tool includes a Change Column Type option for changing the data types of columns on MySQL database tables. The change column type function allows the user to choose a new type, a new length, and a new scale if appropriate for the data type chosen. The tool then generates the appropriate alter table alter column SQL command for changing the data type of the column on the table.

The syntax of the command to change the column type in MySQL is the following:

ALTER TABLE table_name MODIFY COLUMN column_name data_type

Listed below is an example of the SQL generated by the MySQL Alter Table Change Column Type function for the following information:

Database Name: sample
Table Name: employee
Column Name: first_name
New Column Type: CHAR
New Column Length: 25

Note that if the currently selected MySQL database is sample, the database name is not required in the alter table statement.

ALTER TABLE sample.employee MODIFY COLUMN first_name CHAR(25)

Below is a screen shot of the change column type function of the MySQL alter table tool.

MySQL Change Column Type