dbTalk Databases Forums  

temporary table

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss temporary table in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mattes
 
Posts: n/a

Default temporary table - 12-10-2011 , 02:42 PM






Hello,

I am a little bit confused about DB2 temporary tables. (We use MS SQL
Server 2005 at work and we are planning to migrate to DB2.) In MS SQL
Server one can use the following example statement to create a
temporary table (#temp; without defining the columns):

SELECT c1, c2, ... cn INTO #temp FROM schema.table WHERE c1 > 4;

For me it is an easy way to create temporary tables...
How do I do this in DB2?

Thanks
Matthias

Reply With Quote
  #2  
Old   
CRPence
 
Posts: n/a

Default Re: temporary table - 12-10-2011 , 08:02 PM






On 10-Dec-2011 12:42 , mattes wrote:
Quote:
I am a little bit confused about DB2 temporary tables. (We use MS
SQL Server 2005 at work and we are planning to migrate to DB2.) In
MS SQL Server one can use the following example statement to create
a temporary table (#temp; without defining the columns):

SELECT c1, c2, ... cn INTO #temp
FROM schema.table
WHERE c1> 4;

For me it is an easy way to create temporary tables...
How do I do this in DB2?

How the temporary would be used, will influence the choice of type
[and thus syntax] for making the temporary table\result available.

DECLARE GLOBAL TEMPORARY TABLE statement
http://publib.boulder.ibm.com/infoce...c/r0003272.htm

DB2 9.7: Created global temporary tables
Learn how and when to use CGTTs
http://www.ibm.com/developerworks/da...obaltemptable/
"... The main difference between a DGTT <ed: Declared Global Temporary
Table> and a CGTT is that the definition of a CGTT is stored
persistently in the DB2 catalog. A DGTT is created and exist only for
the duration of a user session. Unlike DGTTs, CGTTs are created in a
session and persist after the session is terminated. The definition is
shared across all concurrent sessions, even though the content of a
created temporary table remains private to each session. ...
"

CREATE GLOBAL TEMPORARY TABLE statement
http://publib.boulder.ibm.com/infoce.../r0053719.html

DECLARE GLOBAL TEMPORARY TABLE statement
http://publib.boulder.ibm.com/infoce.../r0003272.html

Or limited to a component of a particular query, a
common-table-expression:

Queries and table expressions
http://publib.boulder.ibm.com/infoce...c/c0004116.htm

Select-statement
http://publib.boulder.ibm.com/infoce...c/r0000879.htm

Regards, Chuck

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.