IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Index on Temporary tables created using WITH clause?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gvshruthi

New User


Joined: 05 Jan 2009
Posts: 4
Location: bangalore

PostPosted: Tue Sep 20, 2011 10:29 am
Reply with quote

I have a legacy SQL query. This has many temporary tables, created dynamically using WITH clause.
Eg:

WITH <temp-table name> (column 1, column2) AS
(Select col1, col2 from <table name>
Where col1 = col2
)

Is it possible to create indexes on such temporary tables? These tables are created only for a particular run. Hence I am not aware if any dynamic index could be created on such tables.

Kindly help me on this.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Tue Sep 20, 2011 11:46 pm
Reply with quote

Hi Shruthi,

Welcome to IBMMAINFRAMES!

Example you have given is not a temporary table, its a sort of a result table that can be referenced in a FROM clause of a SELECT statement that follows the WITH keyword. Its called Common Table Expression, shortly CTE.

But, Indexes can be created on a DECLARE GLOBAL TEMPORARY TABLE.

Check out DB2 V9 SQL Reference --> Chapter 5 Statements --> DECLARE GLOBAL TEMPORARY TABLE

Hope this helps,
Sushanth
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Question regarding ISPF tables with T... TSO/ISPF 11
No new posts To join 2 tables and to join 3rd tabl... DB2 8
No new posts Comment multiple lines in JCL for Tem... JCL & VSAM 4
No new posts Cobol file using index COBOL Programming 2
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:


Back to Top