SQL -Structured Query Language - SQL Table - Alter - Rename Column Tutorial
To rename a column in the existing created table, then we can use an ' ALTER TABLE ' statement with a CHANGE statement.
With this statement, we can also change the data type of the column.
Syntax-
The basic syntax of the ALTER TABLE statement with a CHANGE statement to rename a column in the existing table is given below –
ALTER TABLE table_name
CHANGE
old_colname new_colname
column_datatype;
For example-
If we want to rename column DOB to dateofbirth in the user_detail table
Then use the following syntax-
ALTER TABLE user_detail
CHANGE
DOB dateofbirth
DATE;
This query or statement will rename the DOB to dateofbirth in the user_detail table.
In Mysql Workbench-