View Single Post

   
  #1 (permalink)  
Old 04-29-2008, 08:28 PM
macca
 
Posts: n/a
Default TIMESTAMP Confusion

Hi,

I'm currently studying for the CMDEV Dev-I exam and I'm a bit confused
about the actions of the TIMESTAMP data type.

If i create a table in MySQL 5 like so:

CREATE TABLE test1 (ts1 TIMESTAMP, i INT);

Then the timestamp column is automatically set to DEFAULT CURRENT
TIMESTAMP.

If I issue the insert

INSERT INTO test1 (ts1,i) values (NULL,1);

Then the ts1 (timestamp) column will store the current (insert)
timestamp. Which is right.


OK, so then I make another table,

CREATE TABLE test2 (ts1 TIMESTAMP NOT NULL DEFAULT '0000-00-00
00:00:00', i INT);

and issue the same query again on the new table:

INSERT INTO test2 (ts1,i) values (NULL,1);

The ts1 column STILL contains the current timestamp!

Am I missing something?


Thanks...
Reply With Quote