dqmdlo9674 2016-10-25 17:59 采纳率: 100%
浏览 51
已采纳

VARCHAR到DATE - MySQL

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.

  • 写回答

3条回答 默认 最新

  • duaevb1511 2016-10-25 18:05
    关注

    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
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试