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
Today, this article has collected 30 excellent cas...
Log in to your account export DOCKER_REGISTRY=reg...
Preface add_header is a directive defined in the ...
1. First, create the corresponding folder accordi...
There are many tools available for backing up MyS...
The following case reviews the knowledge points o...
Error description When we install Docker Desktop,...
Select or create a subscription message template ...
Copy code The code is as follows: jQuery.cookie =...
The installation and configuration methods of MyS...
WeChat applet uniapp realizes the left swipe to d...
Get the current time: select current_timestamp; O...
Table of contents Use Cases Reactive API related ...
In this experiment, we configure MySQL standard a...
First, pull the image (or just create a container...