mysql 自动记录数据最后修改时间

原文

 

-- mysql ,还真有这样的说法;

mysql> create table test(
    -> name varchar(10),
    -> uptime timestamp on update current_timestamp
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql>
mysql> insert into test(name ,uptime) values('zhang',now()- 1);
Query OK, 1 row affected (0.01 sec)

mysql>
mysql> select * from test ;
+-------+---------------------+
| name  | uptime              |
+-------+---------------------+
| zhang | 2016-02-25 11:30:23 |
+-------+---------------------+
1 row in set (0.00 sec)

mysql> update test set name = 'lisi';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from test ;
+------+---------------------+
| name | uptime              |
+------+---------------------+
| lisi | 2016-02-25 11:30:24 |
+------+---------------------+
1 row in set (0.00 sec)

mysql>
mysql> drop table test ;
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql>

 

posted @ 2017-09-13 10:03  嘿.嘿.嘿  阅读(4608)  评论(0编辑  收藏  举报