[thelist] MySQL - column with default of NOW()

Andrew Forsberg andrew at thepander.co.nz
Fri Mar 8 19:00:01 CST 2002


>so, i guess this is implying that the default for the DATETIME datatype
>*IS* the current date and time? it seems like that's what it's saying (if
>inserting NULL is the same as inserting NOW()).

They're completely different column types: DATETIME is the
semi-human-readable one, TIMESTAMP is the *nix timestamp. The first
TIMESTAMP column will get set to the system's current timestamp when
it's not explicitly stated in an executed update, or if it's set to
NULL or NOW().

It sort of makes sense, in that DATETIME's 0000-00-00 00:00:00 is
different from NULL; and a TIMESTAMP of 0 is somewhere in 1970, which
is also different from NULL. But being able to set default
expressions for columns would be nicer.

Cheers
Andrew

--



More information about the thelist mailing list