How to rearrange MySQL columns?

前端 未结 5 1512
闹比i
闹比i 2020-12-01 03:35

I need to move the position of existing columns (for better visibility).

How can this be done without affecting the data?

5条回答
  •  醉梦人生
    2020-12-01 03:41

    Based on @VKGS answer:

    If your table called language is:

    |---------------------|------------------|
    |      description    |         name     |
    |---------------------|------------------|
    |      object ...     |         java     |
    |---------------------|------------------|
    |      javascript...  |         nodejs   |
    |---------------------|------------------|
    

    And you want to make the column name the first column or before description, execute this:

    ALTER TABLE language MODIFY description varchar(100) AFTER name;
    

    Don't forget type of the column.

提交回复
热议问题