Find the primary key of the DB2 table.
-
- New Member
- Posts: 5
- Joined: Tue Sep 30, 2014 2:05 pm
Find the primary key of the DB2 table.
Hi,
Is there any way to find the out primary key of a DB2 table? And also the length of the every column with out using any tools, like file-aid? Please help.
Is there any way to find the out primary key of a DB2 table? And also the length of the every column with out using any tools, like file-aid? Please help.
Re: Find the primary key of the DB2 table.
No! You are going to least need a tool to read the DCLGEN for the table - ISPF Browse for example.
Regards
Nic
Nic
- Akatsukami
- Global Moderator
- Posts: 122
- Joined: Tue Oct 20, 2015 3:20 am
- Location: Bloomington, IL
- Contact:
Re: Find the primary key of the DB2 table.
If Apurva-kun has SELECT access on SYSIBM.SYSINDEXES, does this not become a trivial query?
"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli
-
- Global Moderator
- Posts: 826
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Find the primary key of the DB2 table.
and SYSIBM.SYSCOLUMNSAnd also the length of the every column with out using any tools
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Find the primary key of the DB2 table.
Please try this query ("untested")
Code: Select all
SELECT A.COLNAME,
A.COLSEQ,
A.ORDERING,
FROM SYSIBM.SYSKEYS A,
SYSIBM.SYSINDEXES B
WHERE A.IXNAME = B.NAME
AND A.IXCREATOR = B.CREATOR
AND A.IXCREATOR = B.TBCREATOR
AND B.TBNAME = <TABLE NAME>
AND B.TBCREATOR = <TABLE CREATOR>
AND B.UNIQUERULE = ‘P’
zprogrammer
Re: Find the primary key of the DB2 table.
And hw would you use that, Pandora? Remember - no tools! (And SPUFI is a tool.)
Regards
Nic
Nic
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Find the primary key of the DB2 table.
We need to use that by executing a DSNTIAUL program
zprogrammer
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Find the primary key of the DB2 table.
Or Even execute REXX (If TS has some basic knowledge to do with DSNREXX)
zprogrammer
-
- New Member
- Posts: 5
- Joined: Tue Sep 30, 2014 2:05 pm
Re: Find the primary key of the DB2 table.
By without any tools, I meant tools like file-aid or IBM file manager. I did not mean to go to mainframes barefooted.
Thanks Pandora-Box, your query has helped. I also looked at these two queries and they were also helpful: http://publibz.boulder.ibm.com/cgi-bin/ ... 0718164132
Thanks Pandora-Box, your query has helped. I also looked at these two queries and they were also helpful: http://publibz.boulder.ibm.com/cgi-bin/ ... 0718164132
E.8 Retrieving catalog information about parent keys
SYSIBM.SYSCOLUMNS identifies columns of a parent key in column KEYSEQ; a nonzero value indicates the place of a column in the parent key. To retrieve the creator, database, and names of the columns in the parent key of the sample project activity table using SQL statements, execute:
SYSIBM.SYSINDEXES identifies the primary index of a table by the value P in column UNIQUERULE. To find the name, creator, database, and index space of the primary index on the project activity table, execute:Code: Select all
SELECT TBCREATOR, TBNAME, NAME, KEYSEQ FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR = 'DSN8710' AND TBNAME = 'PROJACT' AND KEYSEQ > 0 ORDER BY KEYSEQ;
Code: Select all
SELECT TBCREATOR, TBNAME, NAME, CREATOR, DBNAME, INDEXSPACE FROM SYSIBM.SYSINDEXES WHERE TBCREATOR = 'DSN8710' AND TBNAME = 'PROJACT' AND UNIQUERULE = 'P';
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute