Web lists-archives.com

Re: time stamp specific to columns

On 2015/04/09 13:42, Michael Dykman wrote:
A trigger is far simpler than remodelling your data and adding extra
queries.  They are nothing to be afraid of.

Not afraid of, but to be careful when writing. I have had trouble with my triggers, because I left this&that out. As for timestamping, MySQL already does much which the SQL programmer wants and cannot come at:

"An auto-updated column is automatically updated to the current timestamp when the value of any other column in the row is changed from its current value. An auto-updated column remains unchanged if all other columns are set to their current values."

It would be great if besides the special rows NEW and OLD found in triggers there were also a row of two-state values (BOOL(EAN) with no NULL, or maybe that queer suggestion of CHAR(0) with NULL) that showed whether the field is the same in the update or not, because MySQL, as aforesaid, checks for that, and writing such triggers would be much easier. One could write

	update timestamp

with no worrie over dealing with NULL. A trigger is always called on an attempt, whether there is change or not.

MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql