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
This article example shares the specific code of ...
1. Check the database time zone show variables li...
I personally feel that the development framework ...
Table of contents Introduction to stored procedur...
This article example shares the specific code of ...
Table of contents 1. ES syntax getter and setter ...
radio-and-checkbox Pure CSS to achieve radio and ...
Zero: Uninstall old version Older versions of Doc...
Table of contents 1. Introduction: In this case, ...
This article example shares the specific code of ...
Table of contents Preface Bubble Sort Basic Algor...
When developing a mobile page recently, I encount...
Table of contents Uninstall and install samba Cre...
Introduction to the polling algorithm Many people...
Several typical values of innodb_flush_method f...