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

One thought on “Creating (Declaring), Inserting data into DB2 temporary tables”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.