Oracle Global Temporary Tables
Hello,
In this tutorial, Oracle Global Temp Tables will be covered. Temporary Tables keep data as private for the session that created it. Data will be kept until SESSION or TRANSACTION ends.
The usage need for temp tables is not so much but they may provide much simplicity on specific occasions.
I have used temporary tables with following requirements:
Data calculation user interfaces.
Data privacy.
Temporary tables can be used in two ways.
1. On transaction bases. Session do not need data after commit or rollback.
In this case, data will be deleted after transaction will be end with commit or rollback by the session.
1 2 3 4 5 6 7 |
create global temporary table hr.xx_anil_temp_tbl_tnx ( satir_id number, tutar number, vade date ) on commit delete rows; |
2. On session bases.
Data will be deleted after session is ended, killed, became inactive.
1 2 3 4 5 6 7 |
create global temporary table hr.xx_anil_temp_tbl_session ( satir_id number, tutar number, vade date ) on commit preserve rows; |
Fundamental Properties of Temp Tables
- Truncate will delete data that are created by it’s own session. Other sessions will not be affected.
- Temp tables use TEMP Tablespace.
- Unexpected session ends will also delete data.
- Index, View and triggers can also be used on Global Temp Tables.