in this tutorial, we will learn how to Rename MySQL Column with CHANGE Clause - MySQL Tutorial.


Syntax

ALTER TABLE your_table_name CHANGE original_column_name new_col_name data_type;


Example

look our exiting table column

+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| id    | int(11)      | NO   | PRI | NULL    | auto_increment |
| title | varchar(100) | NO   |     | NULL    |                |
+-------+--------------+------+-----+---------+----------------+


we will alter title to mytitle

alter table test change title mytitle varchar(100);


after table looks like

+---------+--------------+------+-----+---------+----------------+
| Field   | Type         | Null | Key | Default | Extra          |
+---------+--------------+------+-----+---------+----------------+
| id      | int(11)      | NO   | PRI | NULL    | auto_increment |
| mytitle | varchar(100) | YES  |     | NULL    |                |
+---------+--------------+------+-----+---------+----------------+


Thanks it will help you a lot......




Are you facing problems in understanding this article?
You can watch the video. Watch it now