Bug #12765 | CURRENT_DATE function can not be used as a DEFAULT value for a column | ||
---|---|---|---|
Submitted: | 23 Aug 2005 22:54 | Modified: | 24 Aug 2005 11:05 |
Reporter: | Andrija | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S4 (Feature request) |
Version: | last | OS: | Any (any) |
Assigned to: | CPU Architecture: | Any |
[23 Aug 2005 22:54]
Andrija
[24 Aug 2005 11:05]
Valeriy Kravchuk
This limitation is described in the manual (http://dev.mysql.com/doc/mysql/en/create-table.html): "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 as of MySQL 4.1.2." So, you can either use TIMESTAMP datatype, or if you really use "last" (5.0.x) version, you can try to add trigger on INSERT (see http://dev.mysql.com/doc/mysql/en/using-triggers.html for details).