Professional Documents
Culture Documents
The data in a global temporary table is private such that data inserted by a session can only
be accessed by that session. The session-specific rows in a global temporary table can be
preserved for the whole session or just for the current transaction. The ON COMMIT DELETE
ROWS clause indicates that the data should be deleted at the end of the transaction.
In contrast the ON COMMIT PRESERVE ROWS clause indicates that rows should be preserved
until the end of the session.
Miscellaneous Features
• If the TRUNCATE statement is issued against a temporary table only the session specific
• Data in temporary tables is automatically delete at the end of the database session
• Indexes can be created on temporary tables. The content of the index and the scope of
• Views can be created against temporary tables and combinations of temporary and
permanent tables.
• Export and Import utilities can be used to transfer the table definitions but no data
• There are a number of restrictions related to temporary tables but these are version
specific.
---------------------------------------------------------------------------------------------------------------------
Global temporary table is kind of temporary table managed by system. it'll keep in temporary
tablespace till the session remain. there are two methods available i.e.
after deletion we do not need to give any storage management command because global
temporary tables are system managed and after deletion of data space which was occupied by
table are ready to allocate for other use.
SQL> set serveroutput on
declare
v number;
begin
execute immediate 'CREATE GLOBAL TEMPORARY TABLE my_temp_table
( column1 NUMBER,
column2 NUMBER ) ON COMMIT DELETE ROWS';
execute immediate 'insert into my_temp_table values (1,2)';
execute immediate 'select count(*) from my_temp_table' INTO v;
dbms_output.put_line(v);
end;
/