The Information Schema KEY_COLUMN_USAGE table shows which key columns have constraints.

It contains the following columns:

ColumnDescription
CONSTRAINT_CATALOGAlways #def.
CONSTRAINT_SCHEMADatabase name of the constraint.
CONSTRAINT_NAMEName of the constraint (PRIMARY for the primary key).
TABLE_CATALOGAlways #def.
TABLE_SCHEMADatabase name of the column constraint.
TABLE_NAMETable name of the column constraint.
COLUMN_NAMEColumn name of the constraint.
ORDINAL_POSITIONPosition of the column within the constraint.
POSITION_IN_UNIQUE_CONSTRAINTFor foreign keys, the position in the unique constraint.
REFERENCED_TABLE_SCHEMAFor foreign keys, the referenced database name.
REFERENCED_TABLE_NAMEFor foreign keys, the referenced table name.
REFERENCED_COLUMN_NAMEFor foreign keys, the referenced column name.

Comments

Comments loading...