Modify column Vs change column

前端 未结 5 1128
南旧
南旧 2020-11-30 01:33

I know, we can not rename a column using modify column syntax,but can change column syntax.

My question is: what is the main usage of

5条回答
  •  迷失自我
    2020-11-30 02:06

    The difference is whether you want to change the column name, column definition or both.

    CHANGE

    Can rename a column or change its definition, or both.

    ALTER TABLE t1 CHANGE a b BIGINT NOT NULL

    MODIFY

    Can change a column definition but not its name

    ALTER TABLE t1 MODIFY b INT NOT NULL

    RENAME COLUMN

    Can change a column name but not its definition.

    ALTER TABLE t1 RENAME COLUMN b TO a


    You can check the docs for the complete explanation.

提交回复
热议问题