Solution:

  1. Create a new tmp table
  2. Copy data to tmp table
  3. Delete original table
  4. Rename the tmp table’s name to original one’s
# Step 1:
CREATE TABLE tmp_table (
    # your new column types
);

# If you don't need to make any change
CREATE TABLE tmp_table LIKE original_table;

# Step 2:
INSERT INTO tmp_table SELECT * FROM original_table;

# Step 3:
DROP TABLE original_table;

# Step 4:
ALTER TABLE tmp_table RENAME TO original_table; 

Through the above four steps, we can successfully modify the data type of the columns in the MySQL table to avoid the error “mysql modify column type is not supported”.
This method avoids directly modifying the original table by creating a temporary table, ensuring data integrity and consistency.
I hope this article will be helpful to developers who encounter this problem.


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *