How to Rename column name in MySql ?

Created at 13-Feb-2024 , By samar

To rename a column in a MySQL table, you can use the ALTER TABLE statement along with the RENAME keyword.

Raname column name of MySQL table

Query :


The SQL statement ALTER TABLE tags RENAME COLUMN title TO name; is used to rename a column named title to name in the tags table.

Here's a breakdown of the statement:

ALTER TABLE tags: Specifies the table tags that you want to modify.

RENAME COLUMN: Indicates that you want to rename a column.

title: Specifies the current name of the column that you want to rename.

TO name: Specifies the new name that you want to assign to the column.

Create table statement for the tags table. You can use alter command after creating the tags table in your mysql database.

  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(200) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.