Various time functions of Mysql

Source: Internet
Author: User

Various Mysql time functions mysql time functions are rich 1. SQL code SECOND (t. file_time) 2. current Time SQL code now () 3. select DATE_SUB (curdate (), INTERVAL 1 DAY) 4. timestamp default mysql timestamp Field weird problem create table statement: SQL code CREATE TABLE 'testtimestamp' ('id' INT NOT NULL AUTO_INCREMENT, 'file _ time' TIMESTAMP NOT NULL, 'Scan _ time' timestamp null, 'created 'timestamp not null, 'modified' timestamp not null, primary key ('Id ') ENGINE = InnoDB AUTO_INCREMENT = 1 default charset = utf8; after execution, the default value of file_time is CURRENT_TIMESTAMP on update CURRENT_TIMESTAMPscan_time. The default value is NULLcreated and the default value of modified is '2017-00-00 00:00:00, the first timestamp Field of the create statement is CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, and the default value is now ()!!!??? This will lead to a default value. If this field is not found in the update statement, the current time will be filled by default. Modify type: SQL code ALTER TABLE 'database'. 'tablename' CHANGE COLUMN 'columname' TIMESTAMP NOT NULL DEFAULT '2017-00-00 00:00:00 ';

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.