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
K8s k8s is a cluster. There are multiple Namespac...
Robots.txt is a plain text file in which website ...
Software version and platform: MySQL-5.7.17-winx6...
I received a task from the company today, and the...
Table of contents 1. Common function classificati...
Table of contents Container Hierarchy The process...
Scenario: When page A opens page B, after operati...
1. Block-level element: refers to the ability to e...
Table of contents The creation and confusion of n...
Table of contents Introduction to bootstrap and i...
Application nesting of unordered lists Copy code T...
CSS controls the printing style of web pages : Use...
Basic Use <!DOCTYPE html> <html lang=&qu...
For several reasons (including curiosity), I star...
Table of contents Preface Generation of redo log ...