Loading

Creating (Declaring), Inserting data into DB2 temporary tables

Declaring (Creating)


DECLARE GLOBAL TEMPORARY TABLE
SESSION.EMP_TABLE
(EMPID INTEGER NOT NULL,
EMPNAME CHAR(20))
[ON COMMIT DELETE ROWS  | ON COMMIT PRESERVE ROWS]

Even if you do not give the qualifier SESSION, the table will be created as SESSION.EMP_TABLE.
Temporary tables cannot be created with our own qualifier.

Inserting

INSERT INTO SESSION.EMP_TABLE VALUES(1,'KARTHIK')

Fetching

SELECT * FROM SESSION.EMP_TABLE

Related Posts




blog comments powered by Disqus

There's 1 Comment So Far

  •   Mahi
    May 12th, 2014 at 12:10 pm

    what happen to temporary tables when program abends.

Share your thoughts, leave a comment!