Updated on 2023-02-08 GMT+08:00

DISCARD

Function

This syntax releases internal resources associated with a database session.

In cluster 8.2.0, only resources associated with VOLATILE temporary tables can be released.

Precautions

After the DISCARD operation is performed, all volatile temporary table resources in the current session are cleared. A single volatile temporary table resource cannot be cleared.

Syntax

1
DISCARD VOLATILE { TEMPORARY | TEMP }

Parameter Description

  • VOLATILE { TEMPORARY | TEMP }

    Releases resources related to the VOLATILE temporary table in the current session.

Examples

After the DISCARD operation is performed, all resources related to volatile temporary tables in the current session are cleared.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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;
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;