MySQL - How to rename, replace column

If you are not lucky like me, and do not have MySQL 8.0 version or higher, there is only one way to rename column in table is using CHANGE command.

For example:

ALTER TABLE products CHANGE old_column new_column INT NOT NULL;

For MySQL 8.0 you can use next syntax:

ALTER TABLE products RENAME COLUMN old_column TO new_column;

But when you use RENAME command, you are not allow to change data type of this column, only name.

Comments

Popular posts from this blog

CSS Как прикрепить слой (div) к краю

MySQL - How to add JSON column type

Как сделать заголовок модуля активной ссылкой в Joomla 1.5