How to Modify MySQL Column Data Type
There are several operations of ALTER TABLE in MySQL. One of them to modify the column tweaking like DROP, ADD, ALTER, CHANGE, and MODIFY. So if you are one of them who is searching for a solution to customize the data type of an existing table Column, here is a solution for you –
ALTER TABLE table_name MODIFY column_name data_type [ NULL or NOT NULL]
For example, month_year is a datetime type column of vehiclemain table. If you want to change the data type of the column to VARCHAR(33) without affecting the column name, you can use the following SQL command.
ALTER TABLE vehiclemain MODIFY month_year VARCHAR(33) NULL;
Similarly, you can perform the Column name changing, deleting, and adding new Column using the alter operation. You can find more about them in MySQL database here MySQL Altering.