Application Scenario
Get the current time in the database
The difference between NOW() and SYSDATE() in MySQLNOW() takes the time when the statement starts executing, and SYSDATE() takes the dynamic real-time time. Because NOW() is taken from a MySQL variable "TIMESTAMP", and this variable is set when the statement starts executing, it will not change during the entire statement execution process. Execute the following example to understand: SELECT NOW(),SYSDATE(),SLEEP(3),NOW(),SYSDATE() First, NOW() and SYSDATE() are queried, then sleep for 3 seconds, and then NOW() and SYSDATE() are queried again. The results are as follows: Implementation
Example ApplicationCreate a table time with the primary key id and one field date, which defaults to the current system time: CREATE TABLE time( id INT PRIMARY KEY, date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); Insert a piece of data: INSERT INTO time(id) VALUES(1); Query results: This is the end of this article about setting default values for MySQL table field time. For more information about default values for MySQL field time, please search previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Problems installing TensorRT in docker container
>>: Elements of user experience or elements of web design
Overview Operations on any one database are autom...
Element UI implements multiple tables scrolling a...
This article shares the specific code of jQuery t...
The following error message appears when installi...
Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...
This article shares the specific code of js to ac...
Table of contents About Kubernetes Basic environm...
1. Set up HOST on the host Macbook The previous d...
Table of contents 1. Database design 2. Front-end...
The first time I used the essay, I felt quite awkw...
This article shares the specific code of jQuery t...
Table of contents Scene Introduction Deep respons...
usemap is an attribute of the <img> tag, use...
This article shares the implementation code of jQ...
The execution efficiency of MySQL database has a ...