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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 78%

28.4.12 INFORMATION_SCHEMA INNODB_FOREIGN 表28.4.12 The INFORMATION_SCHEMA INNODB_FOREIGN Table

INNODB_FOREIGN 表提供有关 InnoDB 外键 的元数据。The INNODB_FOREIGN table provides metadata about InnoDB foreign keys.

有关相关的使用信息和示例,请参见 第 17.15.3 节,“InnoDB INFORMATION_SCHEMA 模式对象表”。For related usage information and examples, see Section 17.15.3, “InnoDB INFORMATION_SCHEMA Schema Object Tables”.

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

  • ID

    外键索引的名称(不是数字值),前面加上模式(数据库)名称(例如 test/products_fk)。The name (not a numeric value) of the foreign key index, preceded by the schema (database) name (for example, test/products_fk).

  • FOR_NAME

    此外键关系中 子表 的名称。The name of the child table in this foreign key relationship.

  • REF_NAME

    在此外键关系中 父表 的名称。The name of the parent table in this foreign key relationship.

  • N_COLS

    外键索引中的列数。The number of columns in the foreign key index.

  • TYPETYPE

    包含有关外键列信息的一组位标志,按位或组合。0 = ON DELETE/UPDATE RESTRICT,1 = ON DELETE CASCADE,2 = ON DELETE SET NULL,4 = ON UPDATE CASCADE,8 = ON UPDATE SET NULL,16 = ON DELETE NO ACTION,32 = ON UPDATE NO ACTION。A collection of bit flags with information about the foreign key column, ORed together. 0 = ON DELETE/UPDATE RESTRICT, 1 = ON DELETE CASCADE, 2 = ON DELETE SET NULL, 4 = ON UPDATE CASCADE, 8 = ON UPDATE SET NULL, 16 = ON DELETE NO ACTION, 32 = ON UPDATE NO ACTION.

示例Example

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_FOREIGN\G
*************************** 1. row ***************************
      ID: test/fk1
FOR_NAME: test/child
REF_NAME: test/parent
  N_COLS: 1
    TYPE: 1

注释Notes

  • 你必须拥有 PROCESS 权限才能查询此表。You must have the PROCESS privilege to query this table.

  • 使用 INFORMATION_SCHEMA COLUMNS 表或 SHOW COLUMNS 语句查看关于此表列的更多信息,包括数据类型和默认值。Use the INFORMATION_SCHEMA COLUMNS table or the SHOW COLUMNS statement to view additional information about the columns of this table, including data types and default values.