Http://www.111cn.net/database/mysql/55392.htm
This article is to give you the difference between MySQL 5.5 and 5.6 timestamp field DEFAULT current_timestamp on UPDATE current_timestamp, I hope this tutorial will be helpful to you.
mysql5.6 Database:
The code is as follows |
Copy Code |
[bighd" ([email protected] ) [cm]> SELECT version (); +------------+ | version () | +------------+ | 5.6.13-log | +------------+ 1 ROW in SET (0.02 sec) [BIGHD] ([email protected]) [cm]> ALTER TABLE S__uk ADD ' Last_op_time ' TIMESTAMP not NULL DEFAULT current_timestamp on UPDATE current_timestamp; Query OK, 0 ROWS Affected (0.99 sec) records:0 duplicates:0 warnings:0 [BIGHD] ([email& Nbsp;protected]) [cm]> SELECT ID, last_op_time from s__uk LIMIT 1; +----+---------------------+ | id | last_op_time | +----+---------------------+ | 1 | 2013-10-10 10:17:57 | +----+---------------------+ 1 ROW in SET (0.00 sec) |
mysql5.5 Database:
The code is as follows |
Copy Code |
([email protected]) [cm]> SELECT version (); +------------+ | Version () | +------------+ | 5.5.15-log | +------------+ 1 ROW in SET (0.00 sec)
([email protected]) [cm]> ALTER TABLE s__uk ADD ' last_op_time ' TIMESTAMP not NULL DEFAULT current_timestamp on UPDATE current_timestamp; Query OK, 2523 ROWS Affected (0.99 sec) records:2523 duplicates:0 warnings:0
([email protected]) [cm]> SELECT last_op_time from S__uk LIMIT 1; +---------------------+ | Last_op_time | +---------------------+ | 0000-00-00 00:00:00 | +---------------------+ 1 ROW in SET (0.00 sec)
|
Also, have you ever considered what would happen if you only update this field? Will it be the specified time, or is it automatically generated?
copy code |
([email protected]) [cm]> UPDATE s__uk SET last_op_time= ' 2012-12-12 00:00:00 ' WHERE id=1; Query OK, 1 ROW affected (0.07 sec) ROWS matched:1 changed:1 warnings:0 ([EMAIL PR Otected]) [cm]> SELECT ID, last_op_time from s__uk LIMIT 1; +----+---------------------+ | id | last_op_time | +----+---------------------+ | 1 | 2012-12-12 00:00:00 | +----+---------------------+ 1 ROW in SET (0.01 sec) |
Did you get the right wood?
Ps:
How do I tell if a field has multibyte characters (such as Chinese)?
Character_length (value) = LENGTH (value) does not contain multibyte characters.
Length is a byte bytes long and character_length is the character characters length.
PS2:
MongoDB Find ()
After that, the function to beautify/format the output is:
Db.tbl.find (). Pretty ()
? http://www.111cn.net/database/mysql/55392.htm