CREATE VIEW SYS.SYSFOREIGNKEYS ( foreign_creator, foreign_tname, primary_creator, primary_tname, role, columns ) AS SELECT ( SELECT user_name FROM SYS.SYSUSERPERM == SYS.SYSTABLE WHERE table_id = foreign_table_id ), ( SELECT table_name FROM SYS.SYSTABLE WHERE table_id = foreign_table_id ), ( SELECT user_name FROM SYS.SYSUSERPERM == SYS.SYSTABLE WHERE table_id = primary_table_id ), ( SELECT table_name FROM SYS.SYSTABLE WHERE table_id = primary_table_id ), role, ( SELECT list( string( FK.column_name, ' IS ', PK.column_name ) ) FROM SYS.SYSFKCOL KEY JOIN SYS.SYSCOLUMN FK, SYS.SYSCOLUMN PK WHERE foreign_table_id = SYSFOREIGNKEY.foreign_table_id AND foreign_key_id = SYSFOREIGNKEY.foreign_key_id AND PK.table_id = SYSFOREIGNKEY.primary_table_id AND PK.column_id = SYSFKCOL.primary_column_id ) FROM SYS.SYSFOREIGNKEY
Presents foreign key information from SYSFOREIGNKEY and SYSFKCOL in a more readable format.