SQL adaptation guide for IBM DB2 UDB 10.x / Data manipulation |
Informix® temporary tables are created through the CREATE TEMP TABLE DDL instruction or through a SELECT ... INTO TEMP statement. Temporary tables are automatically dropped when the SQL session ends, but they can also be dropped with the DROP TABLE command. There is no name conflict when several users create temporary tables with the same name.
Informix allows you to create indexes on temporary tables. No name conflict occurs when several users create an index on a temporary table by using the same index identifier.
IBM® DB2® 7 supports the DECLARE GLOBAL TEMPORARY TABLE instruction. Native DB2 temporary tables are quite similar to Informix temporary tables with some exceptions:
For more details, see the DB2 documentation.
In accordance with some prerequisites, temporary tables creation in BDL programs can be supported by the database interface.
Fulfill the DB2 prerequisites to create global temporary tables, at minimum you must create a user temporary table space and grant the usage to database users:
CREATE USER TEMPORARY TABLESPACE tempspace01 MANAGED BY AUTOMATIC STORAGE GRANT USE OF TABLESPACE tempspace01 TO PUBLIC
See DB2 documentation for more details.
CREATE TEMP TABLE tmp1 ( col1 INTEGER, col2 CHAR(20) ) SELECT tmp1 FROM table_x WHERE ...