数据仓库服务 GAUSSDB(DWS)-DISCARD:示例

时间:2024-11-28 17:39:00

示例

  • DISCARD VOLATILE临时表

    DISCARD操作后,清理当前会话中所有volatile临时表相关资源。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    CREATE VOLATILE TEMP TABLE TX1(A INT) DISTRIBUTE BY HASH(A);
    CREATE TABLE
    CREATE VOLATILE TEMP TABLE TX2(A INT) DISTRIBUTE BY HASH(A);
    CREATE TABLE
    
    SELECT * FROM TX1;
     a
    ---
    (0 rows)
    SELECT * FROM TX2;
     a
    ---
    (0 rows)
    
    DISCARD VOLATILE TEMP;
    
    SELECT * FROM TX1;
    ERROR:  relation "tx1" does not exist
    LINE 1: SELECT * FROM TX1;
                          ^
    SELECT * FROM TX2;
    ERROR:  relation "tx2" does not exist
    LINE 1: SELECT * FROM TX2;
    
  • DISCARD TEMP
    DISCARD TEMP操作后,清理当前会话中所有临时表相关资源。
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    CREATE GLOBAL TEMP TABLE t_global_temp(a int,b int);
    NOTICE:  The 'DISTRIBUTE BY' clause is not specified. Using round-robin as the distribution mode by default.
    HINT:  Please use 'DISTRIBUTE BY' clause to specify suitable data distribution column.
    CREATE TABLE
    INSERT INTO t_global_temp VALUES(1,1),(2,2);
    INSERT 0 2
    
    CREATE VOLATILE TEMP TABLE t_volatile_temp(a int,b int);
    CREATE TEMP TABLE t_temp(a int,b int);
    
    DISCARD TEMP;
    
    SELECT * FROM t_global_temp;
     a | b
    ---+---
    (0 rows)
    
    SELECT * FROM t_volatile_temp;
    ERROR:  relation "t_volatile_temp" does not exist
    LINE 1: select * from t_volatile_temp;
    
    SELECT * FROM t_temp;
    ERROR:  relation "t_temp" does not exist
    LINE 1: select * from t_temp;
    
support.huaweicloud.com/sqlreference-830-dws/dws_06_0283.html