CHANGE is a MySQL specific sub-clause of ALTER TABLE. It lets you rename an existing column, redefine its data type, nullability, default value, and even reposition it within the table in one atomic operation. Because the entire column definition must be restated, omitting any attribute (such as NOT NULL or DEFAULT) will drop that attribute. CHANGE implicitly preserves the current data as long as the new definition is compatible with existing values. The statement acquires a metadata lock and may rebuild the table depending on the change, which can briefly block writes on large tables. InnoDB retains indexes automatically, but renaming a column referenced by indexes or foreign keys will update those objects under the hood. You cannot use CHANGE to rename multiple columns in a single clause, but you can issue multiple CHANGE clauses separated by commas in the same ALTER TABLE.
table_name
(identifier) - Target table.old_column_name
(identifier) - Current column name.new_column_name
(identifier) - Desired column name.new_definition
(column_definition) - Full column type plus constraints (e.g., INT NOT NULL DEFAULT 0).FIRST
(keyword) - Move column to first position.AFTER column_x
(clause) - Place column after another column.ALTER TABLE, MODIFY, RENAME COLUMN, ADD COLUMN, DROP COLUMN
MySQL 3.23
The omitted attribute is dropped because the full column definition is replaced. Always restate every characteristic you want to keep.
Yes. Separate each CHANGE clause with a comma inside the same ALTER TABLE statement.
MySQL places a metadata lock and may rebuild the table, blocking writes briefly. Online DDL features in newer MySQL versions reduce downtime but do not eliminate locking entirely.
MODIFY changes the definition without renaming the column. CHANGE always requires a new column name, even if the name is unchanged.