Special welcome gift. Get 50% off your first courses with code “AS50”. Find out more!

HomeInterviewHow to change the column name in MySQL?
courses 14

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:

  1. ALTER TABLE table_name     
  2.     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:

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

Share:

Leave A Reply

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

Categories

ads sidebar 1

You May Also Like

Oracle has several modes for shutting down the database: In normal mode, the database is shut down by default. It...
Materialized views are items that contain condensed sets of data from base tables that have been summarized, clustered, or aggregated. They...
Every database in Oracle has a tablespace called SYSTEM, which is generated automatically when the database is created. It also...