Lucas Eduardo Lucas Eduardo - 5 months ago 61
MySQL Question


I'm kinda new at database world and got stucked in my work with the every column in the database that supposed to be DATETIME, or TIMESTAMP, or anything related to date is VARCHAR(250) Ex.: 201610251557.

My question is, there is a way, to change the column to date, withou losing the values on it?

I already tried to change the column structure, but it changes every value to 0000-00-00 00-00.


Safest scenario is:

  1. add a new field with the correct type
  2. update data until new field is populated with appropriate data for all rows
  3. (optional) delete (or rename for archival purposes) old field
  4. (optional) rename new field to original field's name