MySQL Forums
Forum List  »  Newbie

Datetime vs. Timestamp
Posted by: Michael Corr
Date: May 11, 2005 01:01PM

Hi,
I've been reading through the manual and some of the user posts trying to figure out the advantages of using DATETIME vs. TIMESTAMP. I have a simple requirement of updating a time field in my table everytime a new row is inserted or existing row is updated. Can someone please tell me which is better:

create table t1 (col1 int not null, ts timestamp default current_timestamp on update current_timestamp not null)
insert into t1 (col1) values (1);
update t1 set col1=2;

-or-

create table t2 (col1 int not null, ts datetime not null);
insert into t2 values (1, now());
update t2 set col1=2, ts=now();

Both methods seem to have the same effect. Is calling the now() function slower than using current_timestamp ?

thanks,
Michael

Options: ReplyQuote


Subject
Written By
Posted
Datetime vs. Timestamp
May 11, 2005 01:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.