List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 6 2000 10:34pm
Subject:Re: Default a datetime column to now()
View as plain text  
At 2:46 PM -0400 09-06-2000, Jeff Brewer wrote:
>Hello,
>
>Is it possible to default a datetime column to be the time the column is
>inserted?  The following fails for me on 3.23.21:
>
>	create table testtable( samplecol datetime default now())
>
>as does
>
>	create table testtable( samplecol datetime default now)

Default column values must be constants.  You could use a TIMESTAMP
column instead, but then it would also be updated after insert time
if you update any of the other columns.  You may not want that, in which
case leave the column as a DATETIME type and explicitly set it to NOW()
when you create records.

-- 
Paul DuBois, paul@stripped
Thread
Default a datetime column to now()Jeff Brewer6 Sep
  • Re: Default a datetime column to now()Jan Dvorak6 Sep
  • Re: Default a datetime column to now()Paul DuBois7 Sep
  • Re: Default a datetime column to now()Ken Yiem7 Sep
  • Re: Default a datetime column to now()Jan Dvorak7 Sep