There are several ways to get the PK / FK information in Teradata, but it may fail if PK / FK is not defined for the table. And there is a high probability (especially for FK) that they are not defined in the data warehouse. In this case, you need to get external documentation on your datamodel.
dbc.IndicesV contains all indexes, but there is one row per column per index, for example. 4 PK column results in 4 rows defined in the "ColumnPosition" order:
"UniqueFlag" = "Y" indicates a unique index
"IndexType" indicates how it was defined in the Create table: 'K' = primary key, 'U' = unique constraint, 'P' = primary index, 'S' = secondary index
dbc.All_ri_childrenV contains specific FKs.
If for one table there is only "HELP INDEX my_table" for indexes, but in this case I prefer "SHOW TABLE my_table", which returns the full source code.
source share