GBase 8s 在事务中支持(savepoint)保存点,可以在事务中实现类似于快照的功能。可以使用rollback语句,将事务返回至该保存点的状态。
保存点的使用方法以及效果如下:
> create database t1_savepoint with log;
Database closed.
Database created.
> database t1_savepoint;
Database closed.
Database selected.
> begin;
Started transaction.
> create table t1(id int,name varchar(20));
Table created.
> insert into t1 values(1,'liming');
1 row(s) inserted.
> savepoint p1;
Savepoint set.
> select * from t1;
id name
1 liming
1 row(s) retrieved.
> insert into t1 values(2,'lily');
1 row(s) inserted.
> select * from t1;
id name
1 liming
2 lily
2 row(s) retrieved.
> rollback to savepoint p1;
Transaction rolled back to savepoint.
> select * from t1;
id name
1 liming
1 row(s) retrieved.