If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Temporary Tables in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-07, 20:33
khickyphutz khickyphutz is offline
Registered User
 
Join Date: Jan 2007
Posts: 1
Wink Temporary Tables in DB2

Hi All!

I would like to ask your expertise in DB2 SQL scriptingÜ I just transferred to I2 team who are using DB2-AIX. I am just new to DB2 environment and is using MS SQL Server on my previous team.

Now I would like to ask if there are Temporary Table here in DB2?

Give this simple SQL Code (in MS SQL Server 2000), what would be its equivalent in DB2 SQL?

Code
SELECT * INTO #tempTable from ITEMS_TABLE

Creating temporary tables in MS SQL Server is pretty much easy since I just have to assign the set of records using INTO to the assigned temporary table with the "#" sign.

It would be a great help if I will be able to apply this since it will save processing time.


Another thing:
What would be the equivalent script for checking if database object exists here in DB2? Below would be the sample code in MS SQL Server 2000.

Code
IF OBJECT_ID('tempdb.dbo.#outDT') IS NOT NULL
DROP TABLE dbo.#outDT
GO
:

Thank you and God Bless,
MaDz angel:
Reply With Quote
  #2 (permalink)  
Old 01-23-07, 20:38
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
In DB2, you need to first declare the temp table. See DECLARE GLOBAL TEMPORARY TABLE in the SQL Reference Vol 2.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 01-24-07, 01:44
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
khickyphutz, I suggest to download a free DB2 Cookbook. Just "save link as" from link "DB2 9 SQL Cookbook (1290K)". Then see the section Temporary tables on page 273.
Hope this helps,
Grofaty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On