Data Type Default Values
The DEFAULT
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 value
NOW()
or CURRENT_DATE
. The exception is that you can specify CURRENT_TIMESTAMP
as the default for a TIMESTAMP
column.
Reference pages:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html
ALTER TABLE paintings CHANGE creation_date creation_date DATETIME DEFAULT ‘now()’ not null’;
Join the hfvs.net Community for more info/help and ask in the I.T. Section.
— Neddy.
By: Neddy on March 16, 2008
at 12:44 pm
Thanks alot, i found an answer here, but how can i use CURDATE() as a default except in my queries?
By: Ofer on April 19, 2009
at 10:18 am
use DataType timestamp and whenever u add a record it will automatically add current date.
By: speedrider on January 6, 2010
at 11:42 am