标签:mariadb 插入 sele version class mariadb10 闪回查询 for ``
System-Versioned表特性的引入,可以对表进行闪回。完成类似于Oracle的闪回查询。
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)
对插入之前的时间点,做基于时间点的闪回查询,如下:
```shell
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)
标签:mariadb 插入 sele version class mariadb10 闪回查询 for ``
原文地址:https://www.cnblogs.com/zhangshengdong/p/11724954.html