mysql中NOW()和SYSDATE()的区别

mysql中日期函数还是比较常用的。主要有NOW()和SYSDATE()两种,虽然都表示当前时间,但使用上有一点点区别。

NOW()取的是语句开始执行的时间,SYSDATE()取的是动态的实时时间。

NOW() returns a constant time that indicates the time at which the statement began to execute. (Within a stored function or trigger, NOW() returns the time at which the function or triggering statement began to execute.) This differs from the behavior for SYSDATE(), which returns the exact time at which it executes.

https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_now

如下执行示例

SELECT NOW(),LOCALTIME(),LOCALTIMESTAMP,SYSDATE(),SLEEP(3),NOW(),LOCALTIME(),LOCALTIMESTAMP(),SYSDATE()

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注