Remove all zero dates from MySQL database across all Tables

前端 未结 9 1594
-上瘾入骨i
-上瘾入骨i 2021-01-13 14:37

I have plenty of tables in MySQL which which contains zero date in dateTime column 0000-00-00 00:00:00

Using some sort of admin settings, Is it possibl

9条回答
  •  日久生厌
    2021-01-13 14:40

    You can change existing values running that query

    update your_table
    set date_column = '1900-01-01'
    where date_column = '0000-00-00'
    

    And you can change the definition of your table to a specfic default value or null like this

    ALTER TABLE your_table 
    CHANGE date_column date_column date NOT NULL DEFAULT '1900-01-01'
    

提交回复
热议问题