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

Idea PhpStorm - How to fix bugs with incorrect code Inspections and Autocomplete

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

PHP - How to show expected return array elements