CHANGE

CHANGE is a SQL command used in ALTER TABLE clause to modify existing columns within a table. It is principally used to change the type of a column, rename a column, or modify the column's attributes. It is important to note that the CHANGE command requires both the old and new column name, even if it remains the same.

Example

ALTER TABLE Employees CHANGE COLUMN FirstNm FirstName VARCHAR(45);

Output

Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0

Explanation

The CHANGE clause in MySQL is used to change the name and/or data type of a column in a table. In this example, the column named FirstNm is being renamed to FirstName with datatype VARCHAR(45).

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.