文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 28 个 INFORMATION_SCHEMA 表 / 28.3 INFORMATION_SCHEMA 总表 / 28.3.16 INFORMATION_SCHEMA KEY_COLUMN_USAGE 表
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 79%

28.3.16 INFORMATION_SCHEMA KEY_COLUMN_USAGE 表28.3.16 The INFORMATION_SCHEMA KEY_COLUMN_USAGE Table

KEY_COLUMN_USAGE 表描述了哪些键列具有约束。该表不提供关于函数键部分的信息,因为它们是表达式,而该表只提供关于列的信息。The KEY_COLUMN_USAGE table describes which key columns have constraints. This table provides no information about functional key parts because they are expressions and the table provides information only about columns.

KEY_COLUMN_USAGE 表具有以下列:The KEY_COLUMN_USAGE table has these columns:

  • CONSTRAINT_CATALOGCONSTRAINT_CATALOG

    约束所属的目录名称。该值始终为 def。The name of the catalog to which the constraint belongs. This value is always def.

  • CONSTRAINT_SCHEMACONSTRAINT_SCHEMA

    约束所属的模式(数据库)名称。The name of the schema (database) to which the constraint belongs.

  • CONSTRAINT_NAMECONSTRAINT_NAME

    约束的名称。The name of the constraint.

  • TABLE_CATALOG

    表所属的目录名称。该值始终为 def。The name of the catalog to which the table belongs. This value is always def.

  • TABLE_SCHEMA

    表所属的模式(数据库)名称。The name of the schema (database) to which the table belongs.

  • TABLE_NAMETABLE_NAME

    具有约束的表的名称。The name of the table that has the constraint.

  • COLUMN_NAMECOLUMN_NAME

    具有约束的列的名称。The 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

    列在约束中的位置,而不是列在表中的位置。列的位置编号从 1 开始。The column's position within the constraint, not the column's position within the table. Column positions are numbered beginning with 1.

  • POSITION_IN_UNIQUE_CONSTRAINT

    对于唯一约束和主键约束为 NULL。对于外键约束,此列是被引用表中键的序号位置。NULL for unique and primary-key constraints. For foreign-key constraints, this column is the ordinal position in key of the table that is being referenced.

  • REFERENCED_TABLE_SCHEMA

    约束引用的架构名称。The name of the schema referenced by the constraint.

  • REFERENCED_TABLE_NAME

    约束引用的表名称。The name of the table referenced by the constraint.

  • REFERENCED_COLUMN_NAME

    约束引用的列名称。The name of the column referenced by the constraint.

假设有两个表名为 t1 和 t3,它们具有以下定义:Suppose that there are two tables name t1 and t3 that have the following definitions:

CREATE TABLE t1
(
    s1 INT,
    s2 INT,
    s3 INT,
    PRIMARY KEY(s3)
) ENGINE=InnoDB;

CREATE TABLE t3
(
    s1 INT,
    s2 INT,
    s3 INT,
    KEY(s1),
    CONSTRAINT CO FOREIGN KEY (s2) REFERENCES t1(s3)
) ENGINE=InnoDB;

对于这两个表,KEY_COLUMN_USAGE 表有两行记录:For those two tables, the KEY_COLUMN_USAGE table has two rows:

  • 一行记录的 CONSTRAINT_NAME = 'PRIMARY',TABLE_NAME = 't1',COLUMN_NAME = 's3',ORDINAL_POSITION = 1,POSITION_IN_UNIQUE_CONSTRAINT = NULL。One row with CONSTRAINT_NAME = 'PRIMARY', TABLE_NAME = 't1', COLUMN_NAME = 's3', ORDINAL_POSITION = 1, POSITION_IN_UNIQUE_CONSTRAINT = NULL.

    对于 NDB:此值始终为 NULL。For NDB: This value is always NULL.

  • 一行,CONSTRAINT_NAME = 'CO',TABLE_NAME = 't3',COLUMN_NAME = 's2',ORDINAL_POSITION = 1,POSITION_IN_UNIQUE_CONSTRAINT = 1。One row with CONSTRAINT_NAME = 'CO', TABLE_NAME = 't3', COLUMN_NAME = 's2', ORDINAL_POSITION = 1, POSITION_IN_UNIQUE_CONSTRAINT = 1.