Ask a Question related to IBM DB2, Design and Development.
-
Richard Winston #1
SYSIBM Query to Find Which Columns Are Indexed ?
Anyone have anything I can use? Checked the SYSIBM tables and couldn't
figure it out myself.
Thanks.
Richard Winston Guest
-
Specify Query Columns from From
I want to create a form where a user can select from a drop down box which query colums they want to select and in what order. The form will be... -
Convert a query to a list, or find an item in a query
Hi All, I am using CFPOP to retrieve mail from a server, then delete each message after I retrieve it. What I want to do is to check that I don;t... -
How to span a query into 2 columns
I have a query that produces a list of products and some of those products are subdivided into groups within the list. I have a query that... -
SYSIBM Query to Find Cardinality of Indexed Columns
We use DB2 OS/390 v7.1 and the DBA told me that the tool we use to view the cardinality hasn't had its REXX proc updated to pick up changes from v6... -
find max length of data in all columns?
susana73@hotmail.com (Susan Lam) wrote in message news:<7186ed56.0212102328.77cd2980@posting.google.com>... Susan, please do not cross-post on the... -
Mark A #2
Re: SYSIBM Query to Find Which Columns Are Indexed ?
"Richard Winston" <rwinston@NOPSPAM.ORG> wrote in message
news:Yb48b.984397$Bf5.140848@news.easynews.com...If you have DB2 for UNIX, Linux, or Windows try the> Anyone have anything I can use? Checked the SYSIBM tables and couldn't
> figure it out myself.
>
> Thanks.
>
DESCRIBE INDEXES FOR TABLE <tablename>
command as documented in the Command Reference manual.
On the mainframe you can join the SYSKEYS table with the SYSINDEXES table:
where sysindexes.name = syskeys.ixname and sysindexes.creator =
syskeys.ixcreator
and sysindexes.tbname = <the table in question> and tbcreator =
<Authorization ID of the owner of the table>
Mark A Guest
-
P. Saint-Jacques #3
Re: SYSIBM Query to Find Which Columns Are Indexed ?
Look at SYSCAT.INDEXES
You can select tabschema,tabname,colnames from syscat.indexes order by 1,2,3
This should do it.
HTH, Pierre.
Richard Winston wrote:> Anyone have anything I can use? Checked the SYSIBM tables and couldn't
> figure it out myself.
>
> Thanks.
>P. Saint-Jacques Guest
-
Unregistered #4
Re: SYSIBM Query to Find Which Columns Are Indexed ?
It is two step procedure.
1. First find out the index names for the table. and
2. Find out the columns involved for that index.
Here is more detail on that.
1. Use SYSIBM.SYSINDEXES table to get the index name NAME and CREATOR by specifying the table name in TBNAME.
2. Then for each INDEX name, find the related columns in SYSIBM.SYSKEYS. In the where cluase specify IXNAME and IXCREATOR. COLNAME is the answer for your question.
Let me know if you still have any questions.Unregistered Guest
-
Unregistered #5
Re: SYSIBM Query to Find Which Columns Are Indexed ?
I use a couple different queries. It is a different query for 0S390/zOS or Linux/Unix/Windows versions.
First determine the maximum number columns that are indexed:
LUW-
select count(*), indname from SYSIBM.SYSINDEXCOLUSE where indschema='DB2ADMIN' group by indname order by 1 desc
Mainframe-
I do not have a mainframe access at the moment but it is similar query as above. Try-
select count(*), ixname from SYSIBM.SYSKEYS where IXCREATOR='DB2ADMIN' group by ixname order by 1 desc
Find out the schema you are working with - here I just have DB2ADMIN.
There is a less complicated query than these, but I want to see all my indexed columns within an index on one line in the order they appear in the index.
Suppose the quesies above show that the most number of solumns you have in an index is 7.
LUW-
SELECT si.tbname as TBNAME, sic1.colname as COLNAME1, sic2.colname as COLNAME2, sic3.colname as COLNAME3,
sic4.colname as COLNAME4, sic5.colname as COLNAME5, sic6.colname as COLNAME6, sic7.colname as COLNAME7, si.UNIQUERULE
FROM (select * from SYSIBM.SYSINDEXCOLUSE where colseq=1 and INDSCHEMA='DB2ADMIN')sic1
left outer join (select * from SYSIBM.SYSINDEXCOLUSE where colseq=2 )sic2 on sic1.INDNAME = sic2.INDNAME and sic1.INDSCHEMA=sic2.INDSCHEMA
left outer join (select * from SYSIBM.SYSINDEXCOLUSE where colseq=3 )sic3 on sic2.INDNAME = sic3.INDNAME and sic2.INDSCHEMA=sic3.INDSCHEMA
left outer join (select * from SYSIBM.SYSINDEXCOLUSE where colseq=4 )sic4 on sic3.INDNAME = sic4.INDNAME and sic3.INDSCHEMA=sic4.INDSCHEMA
left outer join (select * from SYSIBM.SYSINDEXCOLUSE where colseq=5 )sic5 on sic4.INDNAME = sic5.INDNAME and sic4.INDSCHEMA=sic5.INDSCHEMA
left outer join (select * from SYSIBM.SYSINDEXCOLUSE where colseq=6 )sic6 on sic5.INDNAME = sic6.INDNAME and sic5.INDSCHEMA=sic6.INDSCHEMA
left outer join (select * from SYSIBM.SYSINDEXCOLUSE where colseq=7 )sic7 on sic6.INDNAME = sic7.INDNAME and sic6.INDSCHEMA=sic7.INDSCHEMA,
sysibm.sysindexes si,
sysibm.syscolumns sc
WHERE sic1.indname = si.name
and si.tbname=sc.tbname
and sic1.colname=sc.name;
Mainframe-
SELECT IDXS.TBNAME
, IDXS.TBCREATOR, IDXS.UNIQUERULE, KEYS1.COLNAME, keys2.colname, keys3.colname, keys4.colname, keys5.colname, keys6.colname, keys7.colname,KEYS1.IXNAME
FROM (select * from SYSIBM.SYSKEYS where colseq=1 and IXCREATOR='DB2ADMIN')KEYS1
left outer join (select * from SYSIBM.SYSKEYS where colseq=2)keys2 on keys1.IXNAME = keys2.IXNAME and keys1.IXCREATOR=keys2.IXCREATOR
left outer join (select * from SYSIBM.SYSKEYS where colseq=3)keys3 on keys2.IXNAME = keys3.IXNAME and keys2.IXCREATOR=keys3.IXCREATOR
left outer join (select * from SYSIBM.SYSKEYS where colseq=4)keys4 on keys3.IXNAME = keys4.IXNAME and keys3.IXCREATOR=keys4.IXCREATOR
left outer join (select * from SYSIBM.SYSKEYS where colseq=5)keys5 on keys4.IXNAME = keys5.IXNAME and keys4.IXCREATOR=keys5.IXCREATOR
left outer join (select * from SYSIBM.SYSKEYS where colseq=6)keys6 on keys5.IXNAME = keys6.IXNAME and keys5.IXCREATOR=keys6.IXCREATOR
left outer join (select * from SYSIBM.SYSKEYS where colseq=7)keys7 on keys6.IXNAME = keys7.IXNAME and keys6.IXCREATOR=keys7.IXCREATOR
, SYSIBM.SYSINDEXES IDXS
WHERE IDXS.NAME = KEYS1.IXNAME
AND IDXS.CREATOR = KEYS1.IXCREATOR
order by 1,2,4,5,6,7,8,9,10,11,3;Unregistered Guest



Reply With Quote


