美文网首页
mysql中DATE默认值

mysql中DATE默认值

作者: 萌凉258 | 来源:发表于2021-01-10 15:52 被阅读0次

更新,在stackoverflow上找到了8.0.13版本的解决方案:链接

8.0.13版本的 5.7版本解决方案

经过查看官网,发现5.7版本:链接

With one exception, the default value specified in a DEFAULT clause must be a literal constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such asNOW()orCURRENT_DATE. The exception is that, forTIMESTAMPandDATETIMEcolumns, you can specifyCURRENT_TIMESTAMPas the default. SeeSection 11.2.6, “Automatic Initialization and Updating for TIMESTAMP and DATETIME”.


创建表的时候,想为DATE类型设定默认值当前日期。发现一直报错,百度没有什么好办法。

相关文章

网友评论

      本文标题:mysql中DATE默认值

      本文链接:https://www.haomeiwen.com/subject/fxydaktx.html