Automatic Update modification Time:
int , b timestamp on update current_timestamp); MySQLSelect1, Current_timestamp;
Select from Z; +------+---------------------+| A | b |+------+---------------------+| 1 --: |+------+---------------------+ 1 inch Set (0.00 sec)
mysql> INSERT INTO ZSelect 2, Current_timestamp; Query OK,1Row affected (0.18sec) Records:1Duplicates:0Warnings:0MySQL>Select* fromZ;+------+---------------------+| A | b |+------+---------------------+|1| .- .- - -: -: $||2| .- .- - -: +: to|+------+---------------------+2Rowsinch Set(0.00Sec
mysql> Update ZSeta=a+ - whereA=1; Query OK,1Row affected (0.20sec) Rows matched:1Changed:1Warnings:0MySQL>Select* fromZ;+------+---------------------+| A | b |+------+---------------------+|101| .- .- - -: +: -||2| .- .- - -: +: to|+------+---------------------+2Rowsinch Set(0.00Sec
Record first insertion time:
Mysql> CREATE TABLE X (aint, b timestampdefaultcurrent_timestamp); Query OK,0Rows Affected (0.22sec)MySQL>Select* fromx; EmptySet(0.00sec) MySQL> INSERT into X (a) VALUES (1); Query OK,1Row affected (0.18sec) MySQL>Select* fromx;+------+---------------------+| A | b |+------+---------------------+|1| .- .- - -: -:Geneva|+------+---------------------+1Rowinch Set(0.00sec) MySQL> INSERT into X (a) VALUES (2); Query OK,1Row affected (0.19sec) MySQL>Select* fromx;+------+---------------------+| A | b |+------+---------------------+|1| .- .- - -: -:Geneva||2| .- .- - -: -: *|+------+---------------------+2Rowsinch Set(0.00Sec
Timestamp---Automatic Update modification time and record first insertion time