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 > Sysindexes & syskeys

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-03-11, 11:07
ajh ajh is offline
Registered User
 
Join Date: Apr 2011
Posts: 31
Question Sysindexes & syskeys

My sysindexes has the following data:

select count(distinct(si.index_name))
from qsys2.sysindexes si, qsys2.syskeys sk
where si.table_schema like '%ABC%' -- for all schema's that contain ABC
and si.index_schema = sk.index_schema
and si.index_name = sk.index_name
;
This gives me the count fine. when i remove the count and make the query just ::
select distinct(si.index_name)
from qsys2.sysindexes si, qsys2.syskeys sk
where si.table_schema like '%ABC%' -- for all schema's that contain ABC
and si.index_schema = sk.index_schema
and si.index_name = sk.index_name
;
The query never executes. and then gives me a message " Timeout Disconnected " . I am querying a remote server.
Please help to alter query if there is a better way to do it.


I want a query to return only distinct indexes in all schemas.
The syskeys table has columns on which indexes are defined.
So i actually want to join both these tables and generate a list
of distinct indexes in all schemas.


Tables are huge and are on a remote network so applying only the
distinct clause is not what i am looking out for.
The task i am doing because old indexes in a schema A may be based on column(1) and in new schema B the same index may be based on column(1) & column(2). So i want to actually restore the schema A with the latest definition from schema B.
Please help.

Last edited by ajh; 05-04-11 at 02:47. Reason: Additional Info
Reply With Quote
  #2 (permalink)  
Old 05-04-11, 10:45
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Following this link and you'll find the answer on your question:

Show all indexes on the table as report
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