How can we modify column/s of MySQL table?

MySQLMySQLi Database

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
raja
Published on 19-Feb-2018 08:27:34
Advertisements