I can already get the information i need via IBM i Command DSPFD. Further down the spool file, i see the UNIQUE information for my PF, and all the necessary key fields(see below, our IBMi's language is german, unfortunately).
Now, can i search for this information via catalog tables in the DB2? What i need to query is a) is the table marked as UNIQUE? b) if a is true, show me those UNIQUE key fields.
For Example, i can diplay the columns of my desired table, which is already awesome: syscolumns2 - Example-SQL:
SELECT c.* from qsys2.SYSCOLUMNS2 c
WHERE TRIM(UPPER(table_name)) = UPPER('GENPF510');
source: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzcatalogtbls.htm
Please note, i can't get the information i need via the SYSKEYS table, i already checked this - this table is for informations on indexes, which are not applied on my old PF, in this case (can be added for faster query access).
Spool-Datei anzeigen
Datei . . . . . : QPDSPFD Seite/Zeile 2/5
Steuerung . . . . Spalten 1 - 130
Suchen . . . . .
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3
Wartung des Zugriffspfads . . . . . . . . . : MAINT *IMMED
Eindeutige Schlüsselwerte erforderlich . . : UNIQUE Ja
Zugriffspfad aufgezeichnet . . . . . . . . : Nein
Zugriffspfad . . . . . . . . . . . . . . . : Geschlüsselt
Integritätsart . . . . . . . . . . . . . . : NONE
Anzahl der Schlüsselfelder . . . . . . . . : 1
Satzformat . . . . . . . . . . . . . . . . : GENPR510
Schlüsselfeld . . . . . . . . . . . . . . : ADRE10
Reihenfolge . . . . . . . . . . . . . . : Aufsteigend
Vorzeichen angegeben . . . . . . . . . : UNSIGNED
Zone/Ziffer angegeben . . . . . . . . . : *NONE
Alternative Sortierfolge . . . . . . . : Nein
Sortierfolge . . . . . . . . . . . . . . . : SRTSEQ *HEX
Sprachen-ID . . . . . . . . . . . . . . . . : LANGID DEU
Teildateibeschreibung
Teildatei . . . . . . . . . . . . . . . . . : MBR GENPF510
Teildateiebenen-ID . . . . . . . . . . . : 1010412225901
Erstellungsdatum der Teildatei . . . . . : 12.04.01
Text 'Beschreibung' . . . . . . . . . . . : TEXT Adresse /WH
Weitere ...
F3=Verlassen F12=Abbrechen F19=Links F20=Rechts F24=Weitere Tasten
The information you are looking for can be found in QSYS.QADBXREF.
This SQL query gives you a list of all view and logical files with their keys. DBXUNQ = "U" marks unique keys.
Select DBXFIL , f.DBKFLD, DBKPOS , t.DBXUNQ
from QSYS.QADBXREF t
INNER JOIN QSYS.QADBKFLD f on DBXFIL = DBKFIL and DBXLIB = DBKLIB
INNER JOIN QSYS.QADBFDEP d on d.DBFFDP = t.DBXFIL and d.DBFLIB=t.DBXLIB
where d.DBFFIL = 'GENPF510' and d.DBFLIB = 'YOURLIBRARY'
order by DBXFIL, DBKPOS
My times working with BRAIN AS / Infor AS are long gone. So please excuse the 'YOURLIBRARY' placeholder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.