IBM i DB2目录表/从物理文件中搜索唯一键

问题描述 投票:1回答:1

我已经可以通过IBM i Command DSPFD获得所需的信息。在后台打印文件的下方,我看到了我的PF的UNIQUE信息以及所有必要的关键字段(很遗憾,我们的IBMi语言为德语)。

现在,我可以通过DB2中的目录表搜索此信息吗?我需要查询的是a)该表是否标记为UNIQUE?b)如果a为真,请显示那些UNIQUE键字段。

例如,我可以显示所需表的列,这已经很棒了:syscolumns2-示例SQL:

 SELECT c.* from qsys2.SYSCOLUMNS2 c
    WHERE TRIM(UPPER(table_name)) = UPPER('GENPF510');  

来源:https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzcatalogtbls.htm

请注意,我无法通过SYSKEYS表获得所需的信息,我已经检查了此表-该表用于获取有关索引的信息,在这种情况下,这些信息不适用于我的旧PF(可以添加以获得更快的查询访问权限。)

                                             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                                                          
ibm-midrange db2-400
1个回答
0
投票

您正在寻找的信息可以在QSYS.QADBXREF中找到。

此SQL查询为您提供所有视图和逻辑文件及其键的列表。 DBXUNQ =“ U”标记唯一键。

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

我与BRAIN AS / Infor AS合作的时代早已一去不复返了。因此,请原谅“ YOURLIBRARY”占位符。

© www.soinside.com 2019 - 2024. All rights reserved.