How to set to NULL a datetime with 0000-00-00 00:00:00 value?

后端 未结 5 1672
夕颜
夕颜 2021-02-08 18:37

I need to change a few values on my DB.

I forgot to set nullable to the table and it set to 0000-00-00 00:00:00 by default.

Now I need to convert that value in <

5条回答
  •  鱼传尺愫
    2021-02-08 19:27

    What worked for me is:

    1. Set the field from datetime to varchar(191).
    2. Update all rows with field = '0000-00-00 00:00:00' to NULL.
    3. Set the field back to datetime.

提交回复
热议问题