Updated on 2025-10-23 GMT+08:00

key_column_usage

The key_column_usage view describes which key columns have constraints. This view provides no information about functional key parts because they are expressions. The view provides information only about columns. This view is read-only. All users have the read permission on this view.

Constraint: This view displays only one data record for expression constraints (including composite expression constraints) and does not display column names.

Table 1 information_schema.key_column_usage columns

Name

Type

Description

CONSTRAINT_CATALOG

varchar(512)

Name of the catalog to which the constraint belongs. The value is the name of the current database. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

CONSTRAINT_SCHEMA

varchar(64)

Name of the schema to which the constraint belongs. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

CONSTRAINT_NAME

varchar(64)

Name of the constraint.

TABLE_CATALOG

varchar(512)

Name of the catalog to which the table belongs. The value is the name of the current database. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

TABLE_SCHEMA

varchar(64)

Name of the schema (database) to which the table belongs. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

TABLE_NAME

varchar(64)

Name of the table that has the constraint. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

COLUMN_NAME

varchar(64)

Name of the column that has the constraint. If the constraint is a foreign key, then this is the column of the foreign key, not the column that the foreign key references.

ORDINAL_POSITION

bigint

Column's position within the constraint. Column positions are numbered from 1.

POSITION_IN_UNIQUE_CONSTRAINT

bigint

Null for UNIQUE and PRIMARY KEY constraints. For FOREIGN KEY constraints, this column indicates the ordinal position in key of the table that is being referenced.

REFERENCED_TABLE_SCHEMA

varchar(64)

Name of the schema referenced by the constraint. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

REFERENCED_TABLE_NAME

varchar(64)

Name of the table referenced by the constraint. When lower_case_table_names is set to 0, the value of this column is case-sensitive. When lower_case_table_names is set to 1, the value of this column is case-insensitive.

REFERENCED_COLUMN_NAME

varchar(64)

Name of the column referenced by the constraint.