Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个Date类型的字段,timestamp默认情况下它设置为current_timestamp.
Date
timestamp
current_timestamp
我需要随机更改它(通过添加随机秒数)。本质上,我正在寻找的是类似的东西:
SET Date = current_timestamp + x
其中xis 提供任意整数
x
例如x可以是其中之一:
1000 Round(Rand() * 1000)
预期的结果(正确的时间戳)有时,但很少出现,但几乎一直都是
00-00-0000 00:00:00
研究使用DATE_ADD
DATE_ADD
SET `date` = DATE_ADD(`date`, INTERVAL ROUND(RAND() * 1000) SECONDS)