If you want the data to persist through transaction commits, use the ON COMMIT PRESERVE ROWS option when you create global temporary tables or declare local temporary tables.
# tables
CREATE TABLE temp table( col1 int )
Local Temporary Tables
DECLARE LOCAL TEMPORARY TABLE temp table ( col1 int )
Local Temporary Tables behave just like # tables
Global Temporary Tables
CREATE GLOBAL TEMPORARY TABLE table temp table ( col1 int )
Global Temporary Table structure is static across connections and reboots
Normal hash (#) tables do not need the ON COMMIT PRESERVE ROWS option because the data in a hash table will always persist through transaction commits.