简体   繁体   中英

Will MySQL ALTER TABLE reformat field data?

I need to alter a table to change the Type of a column. If the current column Type is DECIMAL(8,2) and I alter that column to be DOUBLE, will the already-existing data in the column also be changed to reflect the column's new Type?

It should. However, always be safe when altering existing tables.

My preferred way of doing this type of operation is:

  1. make a backup
  2. create a new column
  3. update all rows moving the old data over to new column
  4. inspect the new column for anything wrong and fix if necessary
  5. delete the old column

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM