mysql - CURRENT_DATE/CURDATE() 不能作为默认 DATE 值工作

标签 mysql date default-value

这里是一个非常直截了当的问题,我认为这应该有效,但它没有。为什么不呢?

CREATE TABLE INVOICE(
   INVOICEDATE DATE NOT NULL DEFAULT CURRENT_DATE
)

最佳答案

因为不支持所以不能用

The DEFAULT clause specifies 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. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column

http://dev.mysql.com/doc/refman/5.5/en/create-table.html

关于mysql - CURRENT_DATE/CURDATE() 不能作为默认 DATE 值工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20461030/

相关文章:

mysql - 在主 SELECT 之后使用 SELECT COUNT

mysql - 如何在mysql中设置BLOB列的默认值?

mysql - 了解 MySQL 中的索引顺序

Mysql查询SELECT同名字段

php日期格式转换问题

java - 如何获取时区的本地日期时间

javascript - Date(string) 使用 toLocaleString 显示不同的日期和时间

c++ - 构造函数中指针的默认值是什么意思?

sql-server-2008 - sql server 2008 中 uniqueidentifier 的“绑定(bind)默认值”

php - Mysql PDO 获取时的最大 LONGBLOB 数据长度