The DECLARE GLOBAL TEMPORARY TABLE statements defines a temporary table for your current session. This declared table does not appear in the system catalog and cannot be shared by other sessions. When the session is terminated, the rows of the table are deleted and the temporary table is dropped.
The syntax of DECLARE GLOBAL TEMPORARY TABLE is similar to CREATE TABLE, including creating a table LIKE and creating a table AS. Additionally, you can specify WITH REPLACE to replace an already existing temporary table and certain COMMIT actions. ON COMMIT commit-action ROWS specifies whether the contents of the table should be deleted or preserved at commit. ON ROLLBACK rollback-action ROWS specifies whether the contents of the table should be deleted or preserved on rollback or rollback to a savepoint. NOT LOGGED is used to specify that any changes to the table are not logged, including creation of the table. These actions are specified by keywords DELETE and PRESERVE.
DECLARE GLOBAL TEMPORARY TABLE ORDERS (PARTNO SMALLINT NOT NULL, DESCR VARCHAR(24), QONHAND INT) ON COMMIT DELETE ROWS
For more information, see DECLARE GLOBAL TEMPORARY TABLE in the SQL Reference topic in the
Information Center.