Temporary Table Versioning

A temporary table that is created in the database is called a global temporary table. A temporary table that is declared (rather than created in the database) is called a local temporary table.

A global temporary table is accessible to all users with the appropriate permissions. Each user has his or her own instance of the table, however; only one user ever sees a given set of rows. By default, the rows of a global temporary table are deleted on COMMIT. You can override this default, by specifying ON COMMIT PRESERVE ROWS when you create the temporary table.

Only one user sees any of the rows in a local temporary table. The table is dropped when that user disconnects. When you declare a local temporary table, SAP Sybase IQ issues a savepoint instead of committing the transaction automatically, as it would for a data definition operation on any other type of table. Before creating an index, commit the data in the local temporary table. If you attempt to create an index using uncommitted data, you may see: “Local temporary table, <tablename>, must be committed in order to create an index.”

SAP Sybase IQ makes no distinction between versioning base tables (IQ main store database tables) and versioning global temporary tables. Because the data in any temporary table is accessible to only one user, there will never be more than one write transaction open for a temporary table.

You can enable a global temporary table or local temporary table for RLV storage, even though a temporary table cannot take advantage of RLV's multiple user concurrent write capability. Enabling a temporary table for RLV storage lets you take advantage of the RLV store's low-latency DML.