Bug #39792 Need automatic CURRENT_TIMESTAMP capability in separate TIMESTAMP fields

Submitted: 1 Oct 2008 21:37
Reporter: Kevin Benton (Candidate Quality Contributor) Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: General Severity:S4 (Feature request)
Version:4.1 thru 6.0 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: qc

[1 Oct 2008 21:37] Kevin Benton
Description:
To quote the docs in http://dev.mysql.com/doc/refman/4.1/en/timestamp.html, in section 10.3.1.2. TIMESTAMP Properties as of MySQL 4.1:

"For one TIMESTAMP column in a table, you can assign the current timestamp as the default value and the auto-update value. It is possible to have the current timestamp be the default value for initializing the column, for the auto-update value, or both. It is not possible to have the current timestamp be the default value for one column and the auto-update value for another column."

The same language is used in the 5.0, 5.1, and 6.0 documentation.  Is there a time when this is planned to change at all?

A common desire is to have a created field that gets set when a row is inserted and an updated field that gets updated when a row was last updated.

I don't want to have to create a sproc for every table I have just so I can get separate auto-updated created and updated values stored accurately.  This should be something that MySQL should be able to handle without hand-holding from the one executing an insert or update.

How to repeat:
See description.

Suggested fix:
See description.
[28 Jul 2009 23:47] Dimitriy A
Are there any plans to add this capability? The current workarounds of using triggers or stored procedures are not elegant. Some workarounds are posted in the comments section at http://dev.mysql.com/doc/refman/5.0/en/timestamp.html.

Quoting part of the comment: "...all of these solutions require that the code doing the insert explicitly set a value for the created / inserted timestamp column - whether it is NULL or CURRENT_TIMESTAMP - there doesn't seem to be a way for MySQL to handle this implicitly."

Seems this would require minimal coding.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.058 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
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.