If you want MySQL to obtain the time and date, what kind of function is better? Using the sysdate () function allows MySQL to obtain the time and date. Let's take a look at this function.
MySQL returns the current date + time) function sysdate ():
The sysdate () Date and time function is similar to now (). The difference is that now () is obtained at the execution start time, And sysdate () dynamically obtains the value during function execution. You can see the following example:
Mysql> select now (), sleep (3), now ();
+ --------------------- + ---------- + --------------------- +
| Now () | sleep (3) | now () |
+ --------------------- + ---------- + --------------------- +
| 22:28:21 | 0 | 22:28:21 |
+ --------------------- + ---------- + ------------------- + Mysql> select sysdate (), sleep (3), sysdate ();
+ --------------------- + ---------- + --------------------- +
| Sysdate () | sleep (3) | sysdate () |
+ --------------------- + ---------- + --------------------- +
| 22:28:41 | 0 | 22:28:44 |
+ --------------------- + ---------- + --------------------- +
We can see that although sleep lasts for 3 seconds, the time values of the now () function are the same. The time values obtained by the sysdate () function differ by 3 seconds. In MySQL Manual, sysdate () is described as follows: Return the time at which the function executes.
Sysdate () Date and time functions are rarely used.
Learn more about mysql CONCAT () Functions
MySQL string segmentation and concatenation statements
How to modify the default Character Set of mysql
How does MySQL Delete foreign key definitions?
Four conditions for using the MySQL foreign key