mysql中DATE默认值

更新,在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类型设定默认值当前日期。发现一直报错,百度没有什么好办法。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容