云数据库 GaussDB-闪回表:使用示例

时间:2025-02-12 15:05:23

使用示例

gaussdb=# DROP TABLE IF EXISTS "public".flashtest;NOTICE:  table "flashtest" does not exist, skippingDROP TABLE--创建表flashtestgaussdb=# CREATE TABLE "public".flashtest (col1 INT,col2 TEXT) WITH(storage_type=ustore);CREATE TABLE--查询csngaussdb=# SELECT int8in(xidout(next_csn)) FROM gs_get_next_xid_csn();  int8in  ---------- 79352065(1 rows)--查询当前时间戳gaussdb=# SELECT now();              now              ------------------------------- 2023-09-13 19:46:34.102863+08(1 row)gaussdb=# SELECT * FROM flashtest; col1 | col2 ------+------(0 rows)

--插入数据gaussdb=# INSERT INTO flashtest VALUES(1,'INSERT1'),(2,'INSERT2'),(3,'INSERT3'),(4,'INSERT4'),(5,'INSERT5'),(6,'INSERT6');INSERT 0 6gaussdb=# SELECT * FROM flashtest; col1 |  col2   ------+---------    3 | INSERT3    6 | INSERT6    1 | INSERT1    2 | INSERT2    4 | INSERT4    5 | INSERT5(6 rows)--闪回表至特定的时间戳gaussdb=# TIMECAPSULE TABLE flashtest TO TIMESTAMP to_timestamp ('2023-09-13 19:52:21.551028', 'YYYY-MM-DD HH24:MI:SS.FF');TimeCapsule Tablegaussdb=# SELECT * FROM flashtest; col1 | col2 ------+------(0 rows)gaussdb=# SELECT now();              now              ------------------------------- 2023-09-13 19:54:00.641506+08(1 row)--插入数据gaussdb=# INSERT INTO flashtest VALUES(1,'INSERT1'),(2,'INSERT2'),(3,'INSERT3'),(4,'INSERT4'),(5,'INSERT5'),(6,'INSERT6');INSERT 0 6gaussdb=# SELECT * FROM flashtest; col1 |  col2   ------+---------    3 | INSERT3    6 | INSERT6    1 | INSERT1    2 | INSERT2    4 | INSERT4    5 | INSERT5(6 rows)--闪回表至特定的时间戳gaussdb=# TIMECAPSULE TABLE flashtest TO TIMESTAMP '2023-09-13 19:54:00.641506';TimeCapsule Tablegaussdb=# SELECT * FROM flashtest; col1 | col2 ------+------(0 rows)gaussdb=# DROP TABLE IF EXISTS "public".flashtest;DROP TABLE
support.huaweicloud.com/fg-gaussdb-cent-v8/gaussdb-48-0202.html