How to change the column name in MySQL? | Eklavya Online

How to change the column name in MySQL?

While creating a table, we have kept one of the column names incorrectly. To change or rename an existing column name in MySQL, we need to use the ALTER TABLE and CHANGE commands together. The following are the syntax used to rename a column in MySQL:

ALTER TABLE table_name
CHANGE COLUMN old_column_name new_column_name column_definition [FIRST|AFTER existing_column];
Suppose the column’s current name is S_ID, but we want to change this with a more appropriate title as Stud_ID. We will use the below statement to change its name:

ALTER TABLE Student CHANGE COLUMN S_ID Stud_ID varchar(10);