DATE类型的字段可以具有CURRENT_TIMESTAMP的DEFAULT值吗? [英] Can a field with DATE type have a DEFAULT value with CURRENT_TIMESTAMP?
问题描述
我知道,对于DATETIME列,您可以CURRENT_TIMESTAMP,但是DATE列呢?我不需要小时,分钟和秒,并且在尝试将CURRENT_TIMSTAMP设置为默认值时遇到错误。
谢谢
I know that for a DATETIME column you can you CURRENT_TIMESTAMP but what about a DATE column? I don't need hours, minutes and seconds and while trying to set CURRENT_TIMSTAMP as default for I get an error. Thanks
推荐答案
一个日期
或 time
类型的列可以使用默认值0
定义,但不能使用 curdate()
或 curtime()
。
A date
or time
type columns can be defined with a default 0
but not a curdate()
or curtime()
.
根据 数据类型默认值 :
数据类型规范中的DEFAULT value子句指示列的默认值。除了一个例外,默认值必须为常数;它不能是函数或表达式。例如,这意味着您不能将日期列的默认值设置为诸如NOW()或CURRENT_DATE之类的函数的值。
The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a 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 as NOW() or CURRENT_DATE.
这篇关于DATE类型的字段可以具有CURRENT_TIMESTAMP的DEFAULT值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!