MySQL arrange existing table columns

前端 未结 6 639
鱼传尺愫
鱼传尺愫 2021-01-30 03:35

How can I change the position of a certain existing column in MySQL table?

Ex: I want to move the column username from its current position to

6条回答
  •  野性不改
    2021-01-30 04:24

    you cant change the order of existing columns.

    but u can delete the column u want to change the position and use this command to add it in your desired position.

    ALTER TABLE `MYTABLE` ADD `MYFILED` INT( 5 ) NOT NULL AFTER `POSITION` 
    

    or

    to add a field at the beginning of table

    ALTER TABLE `MYTABLE` ADD `MYFIELD` INT( 5 ) NOT NULL FIRST 
    

提交回复
热议问题