mysql 5.7 stop support zero for date or datetime column

2016-11-28 11:06:00
原創 2036
摘要:mysql 嚴格模式
我們常常喜歡mysql的容錯機製 但是一旦嚴格模式開啟我們慌亂的措手不及例如對於時間的處理我們經常這樣定義 `datetime NOT NULL DEFAULT '0000-00-00 00:00:00'` however this is stoped by mysql in the new version 5.7我們來看看mysql 5.7的changes是如何説明的> Strict mode affects whether the server permits '0000-00-00' as a valid date: If strict mode is not enabled, '0000-00-00' is permitted and inserts produce no warning. If strict mode is enabled, '0000-00-00' is not permitted and inserts produce an error, unless IGNORE is given as well. For INSERT IGNORE and UPDATE IGNORE, '0000-00-00' is permitted and inserts produce a warning.> The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.那麽如何處理這箇問題呢 讓他繼續使用兼容模式你可以看這箇[link]( we can see : using strick mode let us too powerfull
柒 乘 貳 =