Search code examples
oracletemp-tables

Why we require global temporary tables, their practical use cases


I just got to know about the global temporary tables(I use oracle as db) and understood them but not able to know the exact use of these.

As the name suggests they are used to keep temporary data/session and on closing session the data vanishes for that session.

What can be the examples, business use cases where we need to use them.


Solution

  • A possible use case would be a user that has only rights to create reports. These reports use a lot of aggregated data and these information is reused in more than one of the reports. So it would be a good idea to cache the information for this session and this can be done by using temporary tables.

    Another use case would be that you have a reporting framework and want to have an easy way to query information. So you would just call a PLSQL package that puts together the information in a temporary table and after the package has finished you can just do a SELECT * FROM temporary_table.