When running UPDATE ... datetime = NOW(); will all rows updated have the same date/time?(当运行 UPDATE ... datetime = NOW();所有更新的行都会有相同的日期/时间吗?)
问题描述
当你运行类似的东西时:
When you run something similar to:
UPDATE table SET datetime = NOW();
在具有 1 000 000 000 条记录且查询需要 10 秒才能运行的表上,所有行的时间是否完全相同(分钟和秒)还是不同的时间?换句话说,是查询开始的时间还是每行更新的时间?
on a table with 1 000 000 000 records and the query takes 10 seconds to run, will all the rows have the exact same time (minutes and seconds) or will they have different times? In other words, will the time be when the query started or when each row is updated?
我正在运行 MySQL,但我认为这适用于所有数据库.
I'm running MySQL, but I'm thinking this applies to all dbs.
推荐答案
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now
"NOW() 返回一个常数时间,指示语句开始执行的时间.(在存储的例程或触发器中,NOW() 返回例程或触发语句开始执行的时间.)此与 SYSDATE() 的行为不同,它返回从 MySQL 5.0.13 开始执行的确切时间."
"NOW() returns a constant time that indicates the time at which the statement began to execute. (Within a stored routine or trigger, NOW() returns the time at which the routine or triggering statement began to execute.) This differs from the behavior for SYSDATE(), which returns the exact time at which it executes as of MySQL 5.0.13. "
这篇关于当运行 UPDATE ... datetime = NOW();所有更新的行都会有相同的日期/时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当运行 UPDATE ... datetime = NOW();所有更新的行都会有相同的日期/时间吗?


基础教程推荐
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01