Was this helpful?
DECLARE GLOBAL TEMPORARY TABLE
Valid in: SQL, ESQL, OpenAPI, ODBC, JDBC, .NET
The DECLARE GLOBAL TEMPORARY TABLE statement creates a temporary table.
The DECLARE GLOBAL TEMPORARY TABLE statement has the following format:
[EXEC SQL] DECLARE GLOBAL TEMPORARY TABLE [SESSION.]table_name
              (column_name format {, column_name format})
              ON COMMIT PRESERVE ROWS
              WITH NORECOVERY
To create a temporary table by selecting data from another table:
[EXEC SQL] DECLARE GLOBAL TEMPORARY TABLE [SESSION.]table_name
              (column_name {, column_name})
              AS subselect
              ON COMMIT PRESERVE ROWS
              WITH NORECOVERY
table_name
Defines the name of the temporary table.
ON COMMIT PRESERVE ROWS
(Required) Directs the DBMS Server to retain the contents of a temporary table when a COMMIT statement is issued.
WITH NORECOVERY
(Required) Suspends logging for the temporary table.
AS subselect
Defines the subselect, as described in SELECT (interactive).
The DECLARE GLOBAL TEMPORARY TABLE statement creates a temporary table, also referred to as a session-scope table. Temporary tables are useful in applications that need to manipulate intermediate results and want to minimize the processing overhead associated with creating tables.
Last modified date: 08/28/2024