Hello
I would like to be able to analyze foreign key constraints by query on the relational catalog
I am faced with a difficulty in the case where the referenced column does not have the same name as the referencing column
For example, let's say the following DDL
CREATE TABLE SCH1.TAB1
( B1IDEN SMALLINT NOT NULL PRIMARY KEY
, FKIDEN SMALLINT DEFAULT NULL
, B1DATE DATE NOT NULL
, FOREIGN KEY FK01PK00(FKIDEN)
REFERENCES SCH1.TAB0(B0IDEN)
ON DELETE SET NULL
)
When I look at the relational catalog, tables SYSIBM.SYSRELS and SYSIBM.SYSFOREIGNKEYS, I find
the name of the child table (TAB1)
the name of the referenced table (TAB0)
the name of the constraint (FK01PK00)
the name of the column in the child table (FKIDEN)
but not the name of the column in the parent table(B0IDEN)
Where can i find this name in the catalog tables (SYSIBM.SYS*)
I know how to find this information with some tools (BMC, Platinum...), but I would like to find it in the relational catalog
SELECT A.CREATOR, A.TBNAME, A.RELNAME, B.COLNAME, B.COLSEQ,
A.REFTBCREATOR, A.REFTBNAME
FROM SYSIBM.SYSRELS A, SYSIBM.SYSFOREIGNKEYS B
WHERE A.CREATOR = 'DSN8C10'
AND B.CREATOR = 'DSN8C10'
AND A.TBNAME = 'PROJ'
AND B.TBNAME = 'PROJ'
AND A.RELNAME = B.RELNAME
ORDER BY A.RELNAME, B.COLSEQ;