How can we modify column/s of MySQL table?


By using MODIFY keyword with ALTER TABLE command we can modify the column/s of MySQL table. The syntax for the same is as follows;

Syntax

Alter table table_name MODIFY column_name1 datatype, MODIFY column_name2 datatype… MODIFY column_nameN datatype);

Example

In the example below, with the help of MODIFY keyword in ALTER Command, the size of column ‘Address’ and ‘Grade’ has been modified.

mysql> Alter table student modify address varchar(45),Modify Grade Varchar(15);
Query OK, 5 rows affected (0.38 sec)
Records: 5 Duplicates: 0 Warnings: 0

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 20-Jun-2020

131 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements