Bug #30045 desire for auto-updates of multiple timestamp columns in one table
Submitted: 25 Jul 2007 17:02 Modified: 25 Jul 2007 17:40
Reporter: Creighton Higgins Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S4 (Feature request)
Version:5.0 OS:Any
Assigned to: CPU Architecture:Any

[25 Jul 2007 17:02] Creighton Higgins
Description:
For as long as I've been doing this, there's been a need for behavior that addresses the need for a 'created' and 'last_update' field. And for as long as I've been using MySQL, I've always had to implement something at the application layer to deal with the fact that you can't just do this:

CREATE TABLE foo (
  foo_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  last_update TIMESTAMP DEFAULT ON UPDATE CURRENT_TIMESTAMP
)

I can't be the first person to point this out?

How to repeat:
create a table with both. it doesn't work. why am i having to fill this field out for a feature request?
[25 Jul 2007 17:11] Paul DuBois
One (non-application level) strategy is to use a trigger to provide the update behavior. This also can be used with DATETIME columns to simulate TIMESTAMP behavior.
[25 Jul 2007 17:17] MySQL Verification Team
Thank you for the bug report, feature request.
[25 Jul 2007 17:40] Creighton Higgins
Paul, thank you for the response and the tip, I do appreciate it.

However, I still can't help but feel like that's just another workaround, ya know what I mean? We've been doing object persistence layers (and MySQL's always my first choice if it can handle the task) for a good long time now. I guess I find it hard to believe that I'm the only developer that thinks this kind of capability would make life a lot easier.

Thanks again, Cheers,
Creighton