List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 8 2002 12:52am
Subject:Re: NULL timestamps not possible?
View as plain text  
At 16:31 -0800 3/7/02, Shankar Unni wrote:
>Shankar Unni wrote:
>
>>I tried setting a TIMESTAMP column (nullable, not first timestamp 
>>in that table) in mysql 3.23.38) to NULL, but it seems to get the 
>>value 00000000000000.  Is it not possible to set a timestamp column 
>>to NULL?
>
>
>It's even worse: if you explicitly insert the value NULL (as in the 
>keyword "null"), it inserts now() instead.

As documented.

>
>Try:
>
>    create table foo (t timestamp, u timestamp);
>    insert into foo(t) values('');
>	// inserts 0000.... in both t and u.

You're setting the columns to an empty string.  That's not a legal
TIMESTAMP, which is why you get 00000000000000

>
>    insert into foo(t,u) values (null,null);
>	// inserts the value of now() into both t and u.

As it should.

>
>Is this a bug, or a feature I missed in the documentation?

Feature you missed.  Have a look here:

http://www.mysql.com/doc/D/A/DATETIME.html


>
>--
>Shankar.

Thread
NULL timestamps not possible?Shankar Unni8 Mar
  • Re: NULL timestamps not possible?Paul DuBois8 Mar
  • Re: NULL timestamps not possible?Shankar Unni8 Mar
    • Re: NULL timestamps not possible?Paul DuBois8 Mar
  • Re: NULL timestamps not possible?Shankar Unni8 Mar
    • RE: NULL timestamps not possible?Al Caponi8 Mar
    • Re: NULL timestamps not possible?Michael Stassen8 Mar