freddiefujiwara
freddiefujiwara

Reputation: 59079

will a CURRENT_TIMESTAMP field will update automagically if you run an UPDATE statement against other fields in the table?

Will the CURRENT_TIMESTAMP column be updated even if I UPDATE some other column in the row?

Upvotes: 0

Views: 158

Answers (1)

Eric
Eric

Reputation: 95173

Yes, if you set the auto-update value to be CURRENT_TIMESTAMP, it will always update, regardless of which columns you updated. You don't have to specify the field and set it to CURRENT_TIMESTAMP, as it will do it on its own.

Be advised that you cannot have one column with a default value of CURRENT_TIMESTAMP and another column with the auto-update value of CURRENT_TIMESTAMP.

See more in the MySQL docs here.

Upvotes: 3

Related Questions