What are Global Temporary tables

Answer Posted / vivek

Global Temporary tables are session dependant tables which
could be used as temporary storage for calculations, sorting
etc. What I mean by Session dependant is, the data being
stored in the Global Temporary table is not written into the
database or stored anywhere. Once the session ends (in which
the Global Temporary table is used), the data also vanishes.



However the structure would still be available even after
the Session is logged out. Also, the structure is available
to other sessions even when one session is using it, but not
the data. i.e multiple sessions could use the same Global
Temporary table without interfering the data. Each session
could insert/update/delete their own data into the same
Global Temporary table as if the table is available to only
that session. Any data inserted in one session is not
available to another.



Now, why do we need Global Temporary tables? Well, imagine a
requirement where you need to fetch some data from the
database, do some kind of calculations, aggregations and
provide the Result Set (many records) to a Front End. Again,
in the Front End, you need to fetch the Result set may
times, for some purpose. Then you could make use of the
Global Temporary table. Until the user gets disconnected
from that Database session, the data is available for him in
the memory.

Is This Answer Correct ?    22 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is file based approach?

663


How do you take the union of two tables in sql?

731


what is meant by urlencode and urldocode? : Sql dba

770


what are all the different types of indexes? : Sql dba

717


What is output spooling in sql*plus?

741






What are pl sql data types?

726


How can you fetch first 5 characters of the string?

707


How do I kill a query in postgresql?

752


What are string functions in sql?

885


What is count * in sql?

747


Write a sql query to get the third highest salary of an employee from employee_table?

831


How to fetch values from testtable1 that are not in testtable2 without using not keyword?

958


What is identity column in sql server?

718


what are the security recommendations while using mysql? : Sql dba

769


What is dba in sql? : SQL DBA

745