zoukankan      html  css  js  c++  java
  • timestamp ---自动更新修改时间 与 记录首次插入时间

    自动更新修改时间:

    mysql> create table z(a int ,b timestamp on update current_timestamp); 
    
    mysql> insert into z select 1,current_timestamp;
    mysql> select * from z;
    +------+---------------------+
    | a    | b                   |
    +------+---------------------+
    |    1 | 2016-06-26 07:18:45 |
    +------+---------------------+
    1 row in set (0.00 sec)
    mysql> insert into z select 2,current_timestamp; 
    Query OK, 1 row affected (0.18 sec)
    Records: 1  Duplicates: 0  Warnings: 0
    
    mysql> select * from z;
    +------+---------------------+
    | a    | b                   |
    +------+---------------------+
    |    1 | 2016-06-26 07:18:45 |
    |    2 | 2016-06-26 07:19:05 |
    +------+---------------------+
    2 rows in set (0.00 sec)
    mysql> update z set a=a+100 where a=1;
    Query OK, 1 row affected (0.20 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select * from z;
    +------+---------------------+
    | a    | b                   |
    +------+---------------------+
    |  101 | 2016-06-26 07:19:48 |
    |    2 | 2016-06-26 07:19:05 |
    +------+---------------------+
    2 rows in set (0.00 sec)

     记录首次插入时间:

    mysql> create table x (a int, b timestamp default current_timestamp); 
    Query OK, 0 rows affected (0.22 sec)
    
    mysql> select * from x;
    Empty set (0.00 sec)
    
    mysql> insert into x(a) values(1); 
    Query OK, 1 row affected (0.18 sec)
    
    mysql> select * from x;
    +------+---------------------+
    | a    | b                   |
    +------+---------------------+
    |    1 | 2016-06-26 07:14:04 |
    +------+---------------------+
    1 row in set (0.00 sec)
    
    mysql> insert into x(a) values(2);
    Query OK, 1 row affected (0.19 sec)
    
    mysql> select * from x;
    +------+---------------------+
    | a    | b                   |
    +------+---------------------+
    |    1 | 2016-06-26 07:14:04 |
    |    2 | 2016-06-26 07:14:35 |
    +------+---------------------+
    2 rows in set (0.00 sec)
  • 相关阅读:
    K2路由器刷机教程
    GitBook Editor使用教程
    source tree使用教程
    github与github网站push神器
    tgp助手开启逆战游戏无反应
    如何计算服务器指标参数
    排序--堆排序算法
    排序--希尔排序算法
    排序--直接插入排序算法
    排序--冒泡排序算法
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5618970.html
Copyright © 2011-2022 走看看