1.开启闪回功能
gs_guc set -N all -I all -c "enable_default_ustore_table=on" (默认打开)
--## 开启默认支持Ustore存储引擎
gs_guc set -N all -I all -c "version_retention_age=10000" (默认0)
--## 旧版本保留的事务数,超过该事务数的旧版本将被回收清理
gs_guc set -N all -I all -c "enable_recyclebin=on" (默认关闭)
--## 打开回收站
gs_guc set -N all -I all -c "recyclebin_retention_time=15min" (默认15分钟)
--## 置回收站对象保留时间,超过该时间的回收站对象将被自动清理
gs_guc set -N all -I all -c "undo_retention_time=86400" (默认0)
gs_guc set -N all -I all -c "enable_default_ustore_table=on"
gs_guc set -N all -I all -c "version_retention_age=10000"
gs_guc set -N all -I all -c "enable_recyclebin=on"
gs_guc set -N all -I all -c "recyclebin_retention_time=15min"
gs_guc set -N all -I all -c "undo_retention_time=86400"
如果已经开启就不用重复开了。
2.TRUNCATE表
mydb1=> \d
List of relations
Schema | Name | Type | Owner | Storage
--------+-------+-------+-------+------------------------------------------------------------------
public | test2 | table | root | {orientation=row,compression=no,storage_type=USTORE,segment=off}
public | test3 | table | root | {orientation=row,compression=no,storage_type=USTORE,segment=off}
(2 rows)
mydb1=> select * from test2;
id
----
1
2
(2 rows)
mydb1=> TRUNCATE TABLE TEST2;
TRUNCATE TABLE
mydb1=> select * from test2;
id
----
(0 rows)
3.闪回到TRUNCATE 时。
mydb1=> TIMECAPSULE TABLE test2 to before TRUNCATE;
TimeCapsule Table
mydb1=> select * from test2;
id
----
1
2
(2 rows)