I am working on time series data, for which the key column is a timestamp : Time.
There are also many “value” columns for each row.
I am about to shift a whole range of my data by several hours (due to a daylight saving time issue).
For that, I will update the key of several rows, and it might result in some duplicate keys. I would like the duplicate keys on the edge of the date range to be ignore. I want the shifted range to override the old one.
I plan to do something like :
UPDATE IGNORE time_series_table
SET time=time-<some_shift>
WHERE <time in a date-range>
Here is the output of describe <table> for the time key :
Field Type Null Key Default Extra
TimeMeas datetime NO PRI NULL
My question is : Will it shift all the keys at once, or will it try to shift each row one by one, resulting in massive duplicate keys wihthin the shifted range itself ?
Do you have a better way of doing this in mind ?
Thanks in advance
It will shift all the keys at once.
It just failed if any of primary key is duplicated.
With
update ignore, it just skip silently.This is my approach to fix this
then
finally