云数据库 GAUSSDB-TIMECAPSULE TABLE:示例

时间:2024-11-02 18:52:18

示例

-- 删除表tpcds.reason_t2
DROP TABLE IF EXISTS tpcds.reason_t2;
-- 创建表tpcds.reason_t2
openGauss=# CREATE TABLE tpcds.reason_t2
 (
  r_reason_sk    integer,
  r_reason_id    character(16),
  r_reason_desc  character(100)
  )with(storage_type = ustore);
--向表tpcds.reason_t2中插入记录
openGauss=#  INSERT INTO tpcds.reason_t2 VALUES (1, 'AA', 'reason1'),(2, 'AB', 'reason2'),(3, 'AC', 'reason3');
INSERT 0 3
--清空tpcds.reason_t2表中的数据
openGauss=#  TRUNCATE TABLE tpcds.reason_t2;
--查询tpcds.reason_t2表中的数据
openGauss=#  select * from tpcds.reason_t2;
 r_reason_sk | r_reason_id | r_reason_desc 
-------------+-------------+---------------
(0 rows)
--执行闪回TRUNCATE
openGauss=#  TIMECAPSULE TABLE tpcds.reason_t2 to BEFORE TRUNCATE;
openGauss=#  select * from tpcds.reason_t2;
 r_reason_sk |   r_reason_id    |                                            r_reason_desc                                             
-------------+------------------+------------------------------------------------------------------------------------------------------
           1 | AA               | reason1                                                                                             
           2 | AB               | reason2                                                                                             
           3 | AC               | reason3                                                                                             
(3 rows)
--删除表tpcds.reason_t2
openGauss=#  DROP TABLE tpcds.reason_t2;
--执行闪回DROP
openGauss=#  TIMECAPSULE TABLE tpcds.reason_t2 to BEFORE DROP;
TimeCapsule Table
support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_0505.html