background image
<< DECLARE GLOBAL TEMPORARY TABLE statement | ON ROLLBACK DELETE ROWS >>

Temporary tables are useful when

<< DECLARE GLOBAL TEMPORARY TABLE statement | ON ROLLBACK DELETE ROWS >>
Derby Reference Manual
51
These tables do not reside in the system catalogs and are not persistent. Temporary
tables exist only during the connection that declared them and cannot be referenced
outside of that connection. When the connection closes, the rows of the table are deleted,
and the in-memory description of the temporary table is dropped.
Temporary tables are useful when:
· The table structure is not known before using an application.
· Other users do not need the same table structure.
· Data in the temporary table is needed while using the application.
· The table can be declared and dropped without holding the locks on the system
catalog.
Syntax
DECLARE GLOBAL TEMPORARY TABLE
table-Name
{ column-definition [ , column-definition ] * }
[ ON COMMIT {DELETE | PRESERVE} ROWS ]
NOT LOGGED [ON ROLLBACK DELETE ROWS]
table-Name
Names the temporary table. If a schema-Name other than SESSION is specified, an
error will occur (SQLSTATE 428EK). If the schema-Name is not specified, SESSION
is assigned. Multiple connections can define declared global temporary tables with the
same name because each connection has its own unique table descriptor for it.
Using SESSION as the schema name of a physical table will not cause an error, but is
discouraged. The SESSION schema name should be reserved for the temporary table
schema.
column-definition
See
column-definition
for
CREATE TABLE
for more information on
column-definition
.
DECLARE GLOBAL TEMPORARY TABLE
does not allow
generated-column-spec
in the
column-definition
.
Data type
Supported data types are:
· BIGINT
· CHAR
· DATE
· DECIMAL
· DOUBLE
· DOUBLE PRECISION
· FLOAT
· INTEGER
· NUMERIC
· REAL
· SMALLINT
· TIME
· TIMESTAMP
· VARCHAR
ON COMMIT
Specifies the action taken on the global temporary table when a COMMIT operation is
performed.
DELETE ROWS
All rows of the table will be deleted if no hold-able cursor is open on the table. This is
the default value for ON COMMIT. If you specify ON ROLLBACK DELETE ROWS, this