Search code examples
mysqlsql

How to change the column position of MySQL table without losing column data?


I want to change the column positions of my database table without losing data.

For example, here is the current table:

id name email password

To this:

id password name email

Solution

  • Try this:

    ALTER TABLE table_name MODIFY password varchar(20) AFTER id