MySQL table structure uses timestamp to automatically obtain the current time

Source: Internet
Author: User
Tags table definition
I. Miss the ACCESS era. If you want to automatically Insert the current time into the ACCESS table structure, you can enter the default value now () when defining the column to automatically Insert the current time. MySQL does not work. MySQL is a product under the command line by default. If phpMyAdmin is not a graphical interface, it is estimated that

I. Miss the ACCESS era. If you want to automatically Insert the current time into the ACCESS table structure, you can enter the default value now () when defining the column to automatically Insert the current time. MySQL does not work. MySQL is a product under the command line by default. If phpMyAdmin is not a graphical interface, it is estimated that

I. Miss the ACCESS age

If you want to automatically Insert the current time to the ACCESS table structure, you can enter the default value now () during column definition to automatically Insert the current time. MySQL does not work. MySQL is a product under the command line by default. If phpMyAdmin is not a graphical interface, it is estimated that the average person is depressed. Of course, MySQL also developed the corresponding gui tool, of course, exe. Many users of the network service program MySQL are renting virtual hosts, which seems to be a luxury. Hoho, now I have another question. Today's topic is to use the timestamp type in MySQL.

2. do it by yourself.

Previously, the datetime type was used. However, it seems that MySQL cannot automatically obtain the current time. Instead, it must use the php first date ("Y-m-d h: I: s ") and then update it. It seems that I am very sorry for being lazy when I use phpMyAdmin to insert test data. Later, I changed the datetime type of the table column to the timestamp type and changed its default value to CURRENT_TIMESTAMP.

However, this item has a small limitation, that is, only one datestamp column in a table can be set to the default CURRENT_TIMESTAMP, and the second one cannot be set to the default value. The returned result is as follows:

#1293-Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or on update clause

. This seems a bit uncomfortable. Hoho ~

3. Send two figures to compare the results.

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.