Difference between SYSDATE () and NOW () in MySQL _ MySQL
Source: Internet
Author: User
Difference between SYSDATE () and NOW () in MySQL bitsCN.com
Difference between SYSDATE () and NOW () in MySQL five functions in MySQL need to calculate the value of the current time: NOW. return time. Format: 2012-09-23 06: 48: 28 CURDATE. date of the returned Time. Format: 2012-09-23CURTIME. Format: 06: 48: 28UNIX_TIMESTAMP, returns an integer timestamp of time, for example, 1348408108 SYSDATE. the return time is in the same format as the return time of the time () function, but there is a difference. In addition to the differences returned by definitions, the first four functions return the statement-based start execution time, while SYSDATE returns the value of time. Through comparison, we can find the differences between the two functions: NOW () execute the following: [SQL] mysql> select now (), sleep (2), now (); + --------------------- + ---------- + --------------------- + | now () | sleep (2) | now () | + rows + ---------- + ------------------- + | 06:54:29 | 0 | 06:54:29 | + rows + ---------- + ----------------------- + 1 row in set (2.00 sec) the two returned values are the same, it indicates the start time of the statement. SYSDATE: [SQL] mysql> select sysdate (), sleep (2), sysdate (); + --------------------- + ---------- + --------------------- + | sysdate () | sleep (2) | sysdate () | + --------------------- + ---------- + ------------------- + | 06:55:00 | 0 | 06:55:02 | + ----------------------- + ---------- + rows + 1 row in set (2.01 sec) because of this difference, we usually use NOW () when executing the statement, because SYSDATE obtains the real-time at that time, which may lead The returned values of the master database and slave database are different, resulting in inconsistent master/slave data. Other functions are executed as follows: [SQL] mysql> select now (), sysdate (), curdate (), curtime (), unix_timestamp ()/G; * *************************** 1. row ************************** now (): 07:00:05 sysdate (): 07:00:05 curdate (): 2012-09-23 curtime (): 07:00:05 unix_timestamp (): 1348408805 1 row in set (0.00 sec) bitsCN.com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.