Remove all zero dates from MySQL database across all Tables

前端 未结 9 1470
-上瘾入骨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:39

    Alter your Table as

    ALTER TABLE `test_table`
      CHANGE COLUMN `created_dt` `created_dt` date NOT NULL DEFAULT '1900-01-01';
    

    but before Altering table you need to update the existing value as juergen d said

    update test_table
    set created_dt= '1900-01-01'
    where created_dt= '0000-00-00'
    

提交回复
热议问题