Temporary tables in SQL are used for manipulation of data for a short period of time.
It can be used as a accumulator like we have in microprocessor which acts as mediator to store and perform operations into it.
Temporary table in SQL are mainly of two types:
LOCAL TEMPORARY TABLES
GLOBAL TEMPORARY TABLES
Local Temporary Tables have scope within the window in which it is created and used
For ex :
DECLARE LOCAL TEMPORARY TABLE studentdetails
( id int NOT NULL,
name varchar(50) ,
contact varchar(50)
);
Global temporary table can be used outside the query window where is it has been created.
For ex:
CREATE GLOBAL TEMPORARY TABLE suppliers
( supplierid int NOT NULL,
suppliername varchar(50),
contactname varchar(50)
);
0 Comment(s)