====== Native and Managed Temporary Tables ====== HPL/SQL provides you with two options to work with temporary tables: native and managed. Use the [[configuration#hplsqltemptables|hplsql.temp.tables]] option to define how to handle temporary tables, the default value is **native**. ===== Native Temporary Tables ===== When native temporary tables are used HPL/SQL relies on the underlying database to manage temporary tables. HPL/SQL converts DECLARE TEMPORARY TABLE statement to CREATE TEMPORARY TABLE in Hive. Note that Hive supports temporary tables since version 0.14 only. ===== Managed Temporary Tables ===== When [[configuration#hplsqltemptables|hplsql.temp.tables]] is set to **managed**, HPL/SQL creates a regular table in the database and automatically drops it at the end of the session. Note that the schema name and location are defined by [[configuration#hplsqltemptablesschema|hplsql.temp.tables.schema]] and [[configuration#hplsqltemptableslocation|hplsql.temp.tables.location]] options, respectively. Also UUID is added to the table name to prevent name conflicts between multiple sessions. For example, if you declare temporary table //temp1//, HPL/SQL will actually create something like //temp1_3fc162e0590f4e17ae141385cc0e8447//. **Example**: Create a managed temporary table and use it in other SQL statements: SET hplsql.temp.tables = managed; DECLARE TEMPORARY TABLE temp1 ( c1 INT, c2 STRING ); INSERT INTO temp1 SELECT 1, 'A' FROM dual; SELECT * FROM temp1; See also: * [[create-local-temporary-table|CREATE LOCAL TEMPORARY TABLE]] * [[create-volatile-table|CREATE VOLATILE TABLE]] * [[declare-temporary-table|DECLARE TEMPORARY TABLE]] ~~NOTOC~~