You are here: Re: setting default date column to NOW() « PHP SQL « IT news, forums, messages
Re: setting default date column to NOW()

Posted by IchBin on 10/21/05 05:57

laredotornado@zipmail.com wrote:
> Hello,
> I am running MySQL 4. I was curious, how do you make the DATE or
> TIMESTAMP column's default value whatever the time was that the row was
> created. I would prefer not to specify the "NOW()" function in my
> INSERT statement, but rather would like to have that automatically
> happen upon new row creation.
>
> Is it possible?
>
> Thanks, - Dave
>

If the NULL attribute is not specified, setting the column to NULL sets
it to the current timestamp. Note that a TIMESTAMP column which allows
NULL values will not take on the current timestamp unless either its
default value is defined as CURRENT_TIMESTAMP, or either NOW() or
CURRENT_TIMESTAMP is inserted into the column. In other words, a
TIMESTAMP column defined as NULL will auto-update only if it is created
using a definition such as the following:

CREATE TABLE t (ts NULL DEFAULT CURRENT_TIMESTAMP);


Look at this link
http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
--


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация