| Databases InterBase (29) MS-SQL (5) mysql (37) Oracle (1) |
My timestamp field in mysql does not update
Question: To track changes in our database, I added two columns to all my tables namedLAST_CHANGE TIMESTAMP LAST_USER VARCHAR(48) The timestamp field should get updated every time any other column gets updated. For some tables this works, for some it does not. Why is that? Answer: This behavior sounds like you are using a mysql version prior to 4.1.2. And in those tables where it does not work, you probably have another field of type TIMESTAMP already.Explanation: In mysql with versions before 4.1.2 the first TIMESTAMP column in automatically is set to the current timestamp when the record is created if the field value is set to NULL or not not specified at all. During updates the first TIMESTAMP column in table row automatically is updated to the current timestamp when the value of any other column in the row is changed, unless the TIMESTAMP column explicitly is assigned a value other than NULL.
Comments:
| |||||||||