移动整个范围的键
我正在处理时间序列数据,其关键列是时间戳:时间。 每行还有许多“值”列。
我即将将整个数据范围移动几个小时(由于夏令时问题)。 为此,我将更新几行的键,这可能会导致一些重复的键。我希望忽略日期范围边缘的重复键。我希望移动的范围覆盖旧的范围。
我计划做类似的事情:
UPDATE IGNORE time_series_table
SET time=time-<some_shift>
WHERE <time in a date-range>
这是时间键的 describe 的输出:
Field Type Null Key Default Extra
TimeMeas datetime NO PRI NULL
我的问题是:它会立即移动所有键,还是会尝试移动每一行一个接一个,导致在移动范围本身内出现大量重复键?
您有更好的方法吗? 提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它会立即移动所有键。
如果任何主键重复,它就会失败。
使用
updateignore
,它只是默默地跳过。解决这个问题的
这是我最后
方法
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