Oracle: Global Temporary Table

Global temporary table exists solely for your session or whose data persists for the duration of your transaction.

When you create a temporary table, you can specify whether
- it should last for the duration of your session (on commit preserve rows)
- or whether its rows should be deleted when the transaction completes (on commit delete rows)

Unlike a permanent table, a temporary table does not automatically allocate space when it is created. Space will be dynamically allocated for the table as rows are inserted:

create global temporary table YEAR_ROLLUP
(
    EMPNO NUMBER(4),
    ENAME VARCHAR2(9),
    SALARY NUMBER
)
on commit preserve rows;

 Global temporary tables are very useful in optimizing a oracle transaction basically a large PL/SQL block, where we need to hold a large set of data temporary.

1 comment: