云数据库 GAUSSDB-PURGE:示例

时间:2024-11-02 18:53:06

示例

-- 创建表空间reason_table_space
openGauss=#  CREATE TABLESPACE REASON_TABLE_SPACE1 owner tpcds RELATIVE location 'tablespace/tsp_reason1';
-- 在表空间创建表tpcds.reason_t1
openGauss=#  CREATE TABLE tpcds.reason_t1
 (
  r_reason_sk    integer,
  r_reason_id    character(16),
  r_reason_desc  character(100)
  ) tablespace reason_table_space1;
-- 在表空间创建表tpcds.reason_t2
openGauss=#  CREATE TABLE tpcds.reason_t2
 (
  r_reason_sk    integer,
  r_reason_id    character(16),
  r_reason_desc  character(100)
  ) tablespace reason_table_space1;
-- 在表空间创建表tpcds.reason_t3
openGauss=#  CREATE TABLE tpcds.reason_t3
 (
  r_reason_sk    integer,
  r_reason_id    character(16),
  r_reason_desc  character(100)
  ) tablespace reason_table_space1;
-- 对表tpcds.reason_t1创建索引
openGauss=#  CREATE INDEX index_t1 on tpcds.reason_t1(r_reason_id); 
openGauss=#  DROP TABLE tpcds.reason_t1;
openGauss=#  DROP TABLE tpcds.reason_t2;
openGauss=#  DROP TABLE tpcds.reason_t3;
--查看回收站
openGauss=#  SELECT rcyname,rcyoriginname,rcytablespace FROM GS_RECYCLEBIN;
        rcyname        | rcyoriginname | rcytablespace 
-----------------------+---------------+---------------
 BIN$16409$2CEE988==$0 | reason_t1     |         16408
 BIN$16412$2CF2188==$0 | reason_t2     |         16408
 BIN$16415$2CF2EC8==$0 | reason_t3     |         16408
 BIN$16418$2CF3EC8==$0 | index_t1     |             0
(4 rows)
--PURGE清除表
openGauss=#  PURGE TABLE tpcds.reason_t3;
openGauss=#  SELECT rcyname,rcyoriginname,rcytablespace FROM GS_RECYCLEBIN;
        rcyname        | rcyoriginname | rcytablespace 
-----------------------+---------------+---------------
 BIN$16409$2CEE988==$0 | reason_t1     |         16408
 BIN$16412$2CF2188==$0 | reason_t2     |         16408
 BIN$16418$2CF3EC8==$0 | index_t1     |             0
(3 rows)
--PURGE清除索引
openGauss=#  PURGE INDEX tindex_t1;
openGauss=#  SELECT rcyname,rcyoriginname,rcytablespace FROM GS_RECYCLEBIN;
        rcyname        | rcyoriginname | rcytablespace 
-----------------------+---------------+---------------
 BIN$16409$2CEE988==$0 | reason_t1     |         16408
 BIN$16412$2CF2188==$0 | reason_t2     |         16408
(2 rows)
--PURGE清除回收站所有对象
openGauss=#  PURGE recyclebin;
openGauss=#  SELECT rcyname,rcyoriginname,rcytablespace FROM GS_RECYCLEBIN;
        rcyname        | rcyoriginname | rcytablespace 
-----------------------+---------------+---------------
(0 rows)
support.huaweicloud.com/centralized-devg-v2-gaussdb/devg_03_0648.html