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

Query against catalog table


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

New User


Joined: 10 Aug 2007
Posts: 32
Location: Chicago

PostPosted: Wed Sep 10, 2008 12:00 am
Reply with quote

I need to get the list of index names for:

1. Tables with one index and no clustering
2. Tables with more than one index and no clustering

Table Name: SYSIBM.SYSINDEXES
Col names: NAME (INDEX NAME)
TBNAME (TABLE NAME)
CLUSTERING (Whether or not clustering is on - Y/N)

If I try SELECT * FROM SYSIBM.SYSINDEXES WHERE CLUSTERING = 'N', this gives even the other indexes of a table with more than one index. I just need only with no clustering and should be only index on that table or the rest of indexes are also defined as 'no clustering'.

Any help in this regard will be appreciated.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Wed Sep 10, 2008 1:11 pm
Reply with quote

Dinesh,
Following query will provide you with a list of indexes with no clustering and should be only index on that table.

SELECT * FROM SYSIBM.SYSINDEXES WHERE CLUSTERING = 'N' AND
TBNAME IN (SELECT TBNAME FROM SYSIBM.SYSINDEXES GROUP BY TBNAME HAVING COUNT(*) = 1);
Back to top
View user's profile Send private message
dinesh_deadman
Warnings : 1

New User


Joined: 10 Aug 2007
Posts: 32
Location: Chicago

PostPosted: Wed Sep 10, 2008 8:32 pm
Reply with quote

Srihari,

First things first! Thanks much for the response - you were the only one to respond.

a. The query you had sent looks logical to me and makes sense. However, it did not yield the desired results. I am really not sure why.

b. I am looking for indexes with no clustering and should be only index on that table - the other half which is also needed is - indexes with no clustering and remaining indexes should also be defined with no clustering - on that specific table. In other words, also tables could be with more than one index but all of them defined as 'no clustering'.

If you can get this, that would really help me.

Thanks in advance
Dinesh
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Sep 10, 2008 8:55 pm
Reply with quote

Hello Dinesh,

I have checked Srihari query & it's working to get the notcluster indexes & ony index on the table.

Code:
SELECT * FROM SYSIBM.SYSINDEXES WHERE CLUSTERING = 'N' AND
TBNAME IN (SELECT TBNAME FROM SYSIBM.SYSINDEXES GROUP BY TBNAME HAVING COUNT(*) = 1);



For your second I just wanted to know whether you want to have all non cluster index on that table ( Table does not have any cluster index)

If my understandingis correct then please use
Code:
SELECT * FROM SYSIBM.SYSINDEXES WHERE CLUSTERING = 'N' AND
TBNAME IN                                                 
(SELECT TBNAME                                             
 FROM SYSIBM.SYSINDEXES                                   
 GROUP BY TBNAME HAVING                                   
 COUNT(*) >= 1); 


Please let me know if you find any problem
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts RC query -Time column CA Products 3
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top