云数据库 GAUSSDB-VACUUM:示例

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

示例

--创建SCHEMA。
openGauss=# CREATE SCHEMA tpcds;

--创建表tpcds.reason。
openGauss=# CREATE TABLE tpcds.reason
(
  r_reason_sk      integer,
  r_reason_id      character(16),
  r_reason_desc    character(100)
);

--向表中插入多条记录。
openGauss=# INSERT INTO tpcds.reason values(1,'AAAAAAAABAAAAAAA','reason 1'),(2,'AAAAAAAABAAAAAAA','reason 2');

--在表tpcds.reason上创建索引。
openGauss=# CREATE UNIQUE INDEX ds_reason_index1 ON tpcds.reason(r_reason_sk);

--对带索引的表tpcds.reason执行VACUUM操作。
openGauss=# VACUUM (VERBOSE, ANALYZE) tpcds.reason;

--删除索引。
openGauss=# DROP INDEX tpcds.ds_reason_index1 CASCADE;
openGauss=# DROP TABLE tpcds.reason;
openGauss=# DROP SCHEMA tpcds CASCADE;
support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_0508.html