【MySQL】MariaDB10.3新特性--闪回查询



  • MariaDB10.3新特性--闪回查询

    System-Versioned表特性的引入,可以对表进行闪回。完成类似于Oracle的闪回查询。

    修改已有表为System-Versioned

    MariaDB [zsd]> alter table test with system versioning;
    MariaDB [zsd]> select * from test;
    +------+-----------+
    | id   | name      |
    +------+-----------+
    |    1 | 张盛东    |
    |    2 | 刘忠浩    |
    +------+-----------+
    2 rows in set (0.001 sec)
    
    MariaDB [zsd]> select now();
    +---------------------+
    | now()               |
    +---------------------+
    | 2019-09-26 15:38:29 |
    +---------------------+
    1 row in set (0.000 sec)
    
    MariaDB [zsd]> insert into  test values(3,'胡轲');
    Query OK, 1 row affected (0.004 sec)
    

    对插入之前的时间点,做基于时间点的闪回查询,如下:

    MariaDB [zsd]> select \* from test for SYSTEM\_TIME AS OF TIMESTAMP '2019-09-26 15:38:29 ';  
    +------+-----------+  
    | id | name |  
    +------+-----------+  
    | 1 | 张盛东 |  
    | 2 | 刘忠浩 |  
    +------+-----------+  
    2 rows in set (0.000 sec)
    
    MariaDB [zsd]> select \* from test;  
    +------+-----------+  
    | id | name |  
    +------+-----------+  
    | 1 | 张盛东 |  
    | 2 | 刘忠浩 |  
    | 3 | 胡轲 |  
    +------+-----------+  
    3 rows in set (0.001 sec)
    
    
    
      
      
    来自:`https://www.cnblogs.com/zhangshengdong/p/11724954.html`

Log in to reply
 

最新帖子

推荐阅读