Is it possible to rename a column in MySQL without having to repeat its type definition?
Please without having to hack into information_schema.
The ALTER TABLE syntax does not seem to offer such possibility:
ALTER [ONLINE | OFFLINE] [IGNORE] TABLE tbl_name
[alter_specification [, alter_specification] ...]
[partition_options]
ALTER [ONLINE | OFFLINE] [IGNORE] TABLE tbl_name
partition_options
alter_specification:
table_options
[...]
| CHANGE [COLUMN] old_col_name new_col_name column_definition
[FIRST|AFTER col_name]
| MODIFY [COLUMN] col_name column_definition
[FIRST | AFTER col_name]
[...]
More specifically:
When you use
CHANGE
orMODIFY
, column_definition must include the data type and all attributes that should apply to the new column, other than index attributes such asPRIMARY KEY
orUNIQUE
. Attributes present in the original definition but not specified for the new definition are not carried forward.