IBM i DB2 目录表/从物理文件中搜索唯一键
IBM i DB2 catalog tables / search for UNIQUE Keys from Physical Files
我已经可以通过 IBM i Command DSPFD 获得我需要的信息。在假脱机文件的下方,我看到了我的 PF 的唯一信息,以及所有必要的关键字段(请参见下文,不幸的是,我们的 IBMi 语言是德语)。
现在,我可以通过 DB2 中的目录 table 搜索此信息吗?我需要查询的是
a) table 是否标记为 UNIQUE?
b) 如果 a 为真,请显示那些 UNIQUE 关键字段。
例如,我可以显示我想要的 table 的列,这已经很棒了:
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 table 获取我需要的信息,我已经检查过了 - 这个 table 是关于索引的信息,它们是不适用于我的旧 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
您要查找的信息可以在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' 占位符。
我已经可以通过 IBM i Command DSPFD 获得我需要的信息。在假脱机文件的下方,我看到了我的 PF 的唯一信息,以及所有必要的关键字段(请参见下文,不幸的是,我们的 IBMi 语言是德语)。
现在,我可以通过 DB2 中的目录 table 搜索此信息吗?我需要查询的是 a) table 是否标记为 UNIQUE? b) 如果 a 为真,请显示那些 UNIQUE 关键字段。
例如,我可以显示我想要的 table 的列,这已经很棒了: 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 table 获取我需要的信息,我已经检查过了 - 这个 table 是关于索引的信息,它们是不适用于我的旧 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
您要查找的信息可以在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' 占位符。