MySQL Forums
Forum List  »  Performance

Re: Timestamp vs Datetime
Posted by: Erin ONeill
Date: July 22, 2005 11:41AM

I'm using MyIASM tables but here's how I can sneak in a trigger like effect with timestamp IN VERSION 4.0 and 4.1 (this is sooo totally cool):

CREATE TABLE mytable (
my_id tinyint unsigned NOT NULL auto_increment,
last_name varchar(30),
first_name varchar(30) NOT NULL,
active enum('yes','no') NOT NULL default 'yes' ,
created datetime NOT NULL,
last_mod timestamp(14) default 'CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP',
PRIMARY KEY(my_id),
KEY firstname(first_name)
) type=MYISAM;

Insert some data and select it all (I only inserted last_name, first_name). Notice the timestamp. Then update that record, do another select all and notice the timestamp. IT CHANGED!

Cool, huh.
There is a problem with 4.0.20 in that the CURRENT .... needs to be surrounded by quotes.

I tried to use datetime and use on update NOW() or CUR() but nothing worked. Seems 4.0 won't allow functions in datetime but will with timestamp.

or at least that's what I found. If you know differently I'd love to hear!

erin

Options: ReplyQuote


Subject
Views
Written By
Posted
86585
July 17, 2005 05:33PM
47258
July 17, 2005 09:37PM
31962
July 18, 2005 04:51PM
24109
July 21, 2005 05:36PM
55914
July 21, 2005 05:59PM
Re: Timestamp vs Datetime
24043
July 22, 2005 11:41AM
15577
November 21, 2006 01:28PM
15286
November 21, 2006 05:55PM


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.