List:General Discussion« Previous MessageNext Message »
From:George Law Date:May 10 2006 7:06pm
Subject:RE: Can I set UNIX_TIMESTAMP() as default?
View as plain text  
 
Nicholas,

just found something on google:
"In general, this cannot be done. Default values cannot be the return of
a
MySQL function (as much as I'd love to use NOW() for default values!).

However, there's one loophole. When inserting, not specifying a value
for
the first timestamp field in a table will generate the current
timestamp. "


Best work around I can think of is to set your field as an int 
and include unix_timestamp(NOW()) in your inserts



-----Original Message-----
From: Nicolas Verhaeghe [mailto:nicolas@stripped] 
Sent: Wednesday, May 10, 2006 2:33 PM
To: mysql@stripped
Subject: Can I set UNIX_TIMESTAMP() as default?

I would like an integer field to capture the current date as a Unix
Timestamp by default.

But this will not be accepted at all.

I get the error "invalid default value for [field name]"

Is there a workaround?

Thanks!


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=1

Thread
SQL:2003 standardPeng Yi-fan10 May
Re: SQL:2003 standardPeter Brawley10 May
  • Re: SQL:2003 standardRoland Volkmann10 May
    • Can I set UNIX_TIMESTAMP() as default?Nicolas Verhaeghe10 May
RE: Can I set UNIX_TIMESTAMP() as default?George Law10 May