Primary and Foreign Key information in Teradata

Database

Primary and Foreign Key information in Teradata

I am using Teradata SQL Assistant.
The SHOW TABLE provides only the structure of the table but NOT the table relationships like Primary Key and Reference Key.

Can you please let me know which is the command to get the structure and the KEY (relationship)

Thanks
1 REPLY
Teradata Employee

Re: Primary and Foreign Key information in Teradata

Look at DBC.Indices view. The IndexType is set to K for Primary Key.

IndexType: Returns the type of an index as:
• P (Nonpartitioned Primary)
• Q (Partitioned Primary)
• S (Secondary)
• J (join index)
• N (hash index)
• K (primary key)
• U (unique constraint)
• V (value ordered secondary)
• H (hash ordered ALL covering secondary)
• O (valued ordered ALL covering secondary)
• I (ordering column of a composite secondary index)
• M (Multi-column statistics)
• D (Derived column partition statistics)
• 1 (field1 column of a join or hash index)
• 2 (field2 column of a join or hash index)

Also see dbc.ALL_RI_PARENTS, dbc.ALL_RI_Children views.
It is all explained in Data Dictionary manual.