MySQL

How to Change Column Name in MySQL

In this tutorial, we are going to see how to change column name in MySQL. The ALTER TABLE statement is used to add, remove or modify columns in an existing table. Here is the syntax to change column name in a MySQL table:

ALTER TABLE tableName
    CHANGE COLUMN oldName newName 
      type
      [ FIRST | AFTER columnName ]

 

 

How to Change Column Name in MySQL

The following query renames the column called “name” to “lastname” and will have the following constraint varchar(50) NOT NULL.

ALTER TABLE users
  CHANGE COLUMN name lastname
    varchar(50) NOT NULL;
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *