on 2012 Mar 07 5:53 PM
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.
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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".
Don't tell the auditors... 🙂
User | Count |
---|---|
62 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.