MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Index and Column for tables

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
kingmakerofindia
Beginner


Joined: 14 Jul 2006
Posts: 5
Topics: 3

PostPosted: Tue Feb 08, 2011 3:39 am    Post subject: Index and Column for tables Reply with quote

Hi,

I want to extract the Index name and associated column names for all the tables under one creator.

Please suggest, if this can be achieved by SQL statement

Thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Feb 08, 2011 4:38 am    Post subject: Reply with quote

yes it can and be found easily in the manuals, just have to look.

following works for me

Code:

SELECT SUBSTR(I.TBNAME,1,20) AS TBNAME
     , SUBSTR(K.IXNAME,1,12) AS IXNAME
     , SUBSTR(K.COLNAME,1,16) AS COLNAME
     , K.COLSEQ AS SEQ
     , REPLACE(REPLACE(SUBSTR(DIGITS(K.COLNO),2,4),'00','  ')
         ,' 0', '  ') AS COLN
     , I.UNIQUERULE AS U_D
     , K.ORDERING AS ORD
     , SUBSTR(COLTYPE,1,8) AS COLTYPE
     , LENGTH AS LEN
     , NULLS
FROM SYSIBM.SYSKEYS K
   , SYSIBM.SYSINDEXES I
   , SYSIBM.SYSCOLUMNS C
WHERE K.IXCREATOR = 'your creator name' <<<<<<<<<<<<<<<<<
  AND I.TBCREATOR = 'your creator name'   <<<<<<<<<<<<<<<<<
  AND C.TBCREATOR = 'your creator name'  <<<<<<<<<<<<<<<<<
  AND I.NAME = K.IXNAME
   AND C.NAME = K.COLNAME
   AND I.TBNAME = C.TBNAME
   AND I.TBNAME NOT IN (
                       'DSN_FUNCTION_TABLE'
                      ,'DSN_STATEMENT_CACHE_AUX'
                      ,'DSN_STATEMENT_CACHE_TABLE'
                      ,'DSN_STATEMNT_TABLE'
                      ,'PLAN_HISTORY'
                      ,'PLAN_TABLE'
                     )
 ORDER BY 1, 2, 4
 WITH UR
 ;

_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kingmakerofindia
Beginner


Joined: 14 Jul 2006
Posts: 5
Topics: 3

PostPosted: Wed Feb 09, 2011 1:49 am    Post subject: Reply with quote

Thanks Dick, it is working fine
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Feb 09, 2011 2:39 am    Post subject: Reply with quote

running the sql via DSNTEP2 (batch job)
and then using the below DFSORT control statements to parse the output
will create a Reclen(118) PS that can be viewed.
Code:

SORT FIELDS=COPY
INCLUDE COND=(1,30,SS,EQ,C'_!')
INREC PARSE=(%01=(STARTAFT=C'_! ',FIXLEN=118)),
      BUILD=(%01)


of course, if you use another utility, the output of the SQL will be different.

the following will create a RecLen(118) PS file with all columns for all tables:
Code:

SELECT SUBSTR(TBNAME,1,20) AS TBNAME
     , SUBSTR(NAME,1,16) AS COLNAME
     , COLNO
     , COLTYPE
     , LENGTH
     , SCALE
     , NULLS
FROM SYSIBM.SYSCOLUMNS
WHERE TBCREATOR = 'your creator name'  <<<<<<<<<<<<<<<<<<<<<
AND TBNAME NOT IN (
                   'DSN_FUNCTION_TABLE'
                  ,'DSN_STATEMENT_CACHE_AUX'
                  ,'DSN_STATEMENT_CACHE_TABLE'
                  ,'DSN_STATEMNT_TABLE'
                  ,'PLAN_HISTORY'
                  ,'PLAN_TABLE'
                  )
ORDER BY 1,3
WITH UR;

sort control statements same as for indexes

or you can modify the sort control statements and generate a RecLen(96) for the columns.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Feb 09, 2011 11:10 am    Post subject: Reply with quote

dbzTHEdinosauer wrote:
running the sql via DSNTEP2 (batch job)
and then using the below DFSORT control statements to parse the output
will create a Reclen(118) PS that can be viewed.


dbzTHEdinosauer,

Why can't you just use DSNTIAUL and avoid the sort step completely? You can convert the integer and decimal columns to readable format using CHAR/DIGITS functions and convert varchar columns to fixed length char columns using CHAR function.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Feb 10, 2011 3:44 am    Post subject: Reply with quote

you can.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group