mysql5.6 Database:
The code is as follows |
Copy Code |
[BIGHD] (root@127.0.0.1) [cm]> SELECT version (); +------------+ | Version () | +------------+ | 5.6.13-log | +------------+ 1 ROW in SET (0.02 sec)
[BIGHD] (root@127.0.0.1) [cm]> ALTER TABLE s__uk ADD ' last_op_time ' TIMESTAMP not NULL DEFAULT current_timestamp on UPDATE CURR Ent_timestamp; Query OK, 0 ROWS Affected (0.99 sec) records:0 duplicates:0 warnings:0
[BIGHD] (root@127.0.0.1) [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:
code is as follows |
copy code |
(root@localhost) [cm]> SELECT version (); +------------+ | Version () | +------------+ | 5.5.15-log | +------------+ 1 ROW in SET (0.00 sec)
(root@localhost) [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
(root@localhost) [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 updated this field? Will it be the time specified, or is it automatically generated?
The code is as follows |
Copy Code |
(root@localhost) [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
(root@localhost) [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)
|
Guess what, wood?
Ps:
How do I determine if there are multibyte characters in a field (such as Chinese)?
Character_length (value) = LENGTH (value) does not contain multibyte characters.
Length is the byte bytes length, Character_length is the character characters length.
PS2:
MongoDB Find ()
Then the function of beautifying/formatting the output is:
Db.tbl.find (). Pretty ()