Is there a way of stopping DEFAULT TIMESTAMP columns from updating the timestamp when you perform an UPDATE statement? We need to run an update statement on a table to fix up some data, however we don't want that update to be reflected by the UpdatedAt default timestamp column. asked 07 Mar '12, 17:53 Nick Brooks |
You can just include the column with a value in your update statement: Update table set UpdatedAt ='2012-01-01' Will change the value to the 1st January... you can even do something like this: Update table set UpdatedAt = UpdatedAt, ... This will leave the value as before answered 08 Mar '12, 02:59 Martin Just to add: The method Martin has shown does work that way since a DEFAULT TIMESTAMP is a default (though a particular one), and you can always overwrite a column default value simply by specifying a value for the column... We use the "set UpdatedAt = UpdatedAt" form regularly to prevent such meaningful timestamps from getting updated when doing "maintenance tasks".
(08 Mar '12, 03:45)
Volker Barth
Replies hidden
Well, the TRANSLOG will tell:)
(08 Mar '12, 08:51)
Volker Barth
|