NOW(),SYSDATE()和&之间的区别MySQL中的CURRENT_DATE() [英] Difference between NOW(), SYSDATE() & CURRENT_DATE() in MySQL
问题描述
MySQL中NOW()
,SYSDATE()
和CURRENT_DATE()
之间的区别以及可以在实际情况下使用的地方.
What difference between NOW()
, SYSDATE()
, CURRENT_DATE()
in MySQL and where it can be used in real scenario .
当我向表中插入数据并且列数据类型为TIMESTAMP
时,都尝试了NOW()
,SYSDATE()
,Current_Date()
的所有日期和时间.
I tried NOW()
,SYSDATE()
,Current_Date()
when I insert data into a table and column datatype is TIMESTAMP
all are given same date and time.
推荐答案
Current_date()仅会提供日期.
now()为您提供开始执行语句,过程等的日期时间.
sysdate()为您提供当前日期时间.
在now()1 sysdate()1之间等待5秒钟,然后查询以下内容(向右滚动),以秒为单位:
Current_date() will only give you the date.
now() give you the datetime when the statement,procedure etc... started.
sysdate() give you the current datetime.
Look at the seconds after waiting 5 seconds between now()1 sysdate()1 with the following query (scroll to the right):
select now(),sysdate(),current_date(),sleep(5),now(),sysdate();
-- will give
-- now() sysdate() current_date() sleep(5) now()1 sysdate()1
-- 6/10/2014 2:50:04 AM 6/10/2014 2:50:04 AM 6/10/2014 12:00:00 AM 0 6/10/2014 2:50:04 AM 6/10/2014 2:50:09 AM
这篇关于NOW(),SYSDATE()和&之间的区别MySQL中的CURRENT_DATE()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!