Skip navigation links

MySQL Forums :: Performance :: Timestamp vs Datetime


Advanced Search

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
Timestamp vs Datetime 83669 Tom Dean 07/17/2005 05:33PM
Re: Timestamp vs Datetime 45783 Benoit St-Jean 07/17/2005 09:37PM
Re: Timestamp vs Datetime 30790 Erin ONeill 07/18/2005 04:51PM
Re: Timestamp vs Datetime 23198 Allen Arakaki 07/21/2005 05:36PM
Re: Timestamp vs Datetime 54799 Allen Arakaki 07/21/2005 05:59PM
Re: Timestamp vs Datetime 22976 Erin ONeill 07/22/2005 11:41AM
Re: Timestamp vs Datetime 15068 Erick Papadakis 11/21/2006 01:28PM
Re: Timestamp vs Datetime 14636 KimSeong Loh 11/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.