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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

28.4.20 INFORMATION_SCHEMA INNODB_INDEXES 表28.4.20 The INFORMATION_SCHEMA INNODB_INDEXES Table

INNODB_INDEXES 表提供有关 InnoDB 索引的元数据。The INNODB_INDEXES table provides metadata about InnoDB indexes.

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

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

  • INDEX_ID

    索引的标识符。索引标识符在实例的所有数据库中都是唯一的。An identifier for the index. Index identifiers are unique across all the databases in an instance.

  • NAMENAME

    索引的名称。大多数由 InnoDB 隐式创建的索引具有一致的名称,但索引名称不一定是唯一的。例如:用于主键索引的 PRIMARY,当未指定主键时表示主键的索引 GEN_CLUST_INDEX,以及用于外键约束的 ID_IND、FOR_IND 和 REF_IND。The name of the index. Most indexes created implicitly by InnoDB have consistent names but the index names are not necessarily unique. Examples: PRIMARY for a primary key index, GEN_CLUST_INDEX for the index representing a primary key when one is not specified, and ID_IND, FOR_IND, and REF_IND for foreign key constraints.

  • TABLE_ID

    表示与索引相关联的表的标识符;此值与 INNODB_TABLES.TABLE_ID 相同。An identifier representing the table associated with the index; the same value as INNODB_TABLES.TABLE_ID.

  • TYPETYPE

    一个从位级信息导出的数值,用于标识索引类型。0 = 非唯一二级索引;1 = 自动生成的聚簇索引(GEN_CLUST_INDEX);2 = 唯一非聚簇索引;3 = 聚簇索引;32 = 全文索引;64 = 空间索引;128 = 关于虚拟生成列的二级索引。A numeric value derived from bit-level information that identifies the index type. 0 = nonunique secondary index; 1 = automatically generated clustered index (GEN_CLUST_INDEX); 2 = unique nonclustered index; 3 = clustered index; 32 = full-text index; 64 = spatial index; 128 = secondary index on a virtual generated column.

  • N_FIELDS

    索引键中的列数。对于GEN_CLUST_INDEX索引,此值为 0,因为索引是使用人工值而非实际表列创建的。The number of columns in the index key. For GEN_CLUST_INDEX indexes, this value is 0 because the index is created using an artificial value rather than a real table column.

  • PAGE_NO

    索引 B 树的根页号。对于全文索引,PAGE_NO 列未使用,并设为 -1 (FIL_NULL),因为全文索引分布在几个 B 树(辅助表)中。The root page number of the index B-tree. For full-text indexes, the PAGE_NO column is unused and set to -1 (FIL_NULL) because the full-text index is laid out in several B-trees (auxiliary tables).

  • SPACE

    索引所在表空间的标识符。0 表示 InnoDB 系统表空间。其他任何数字表示在 按表存储文件 模式下使用单独的 .ibd 文件创建的表。在执行 TRUNCATE TABLE 语句之后,此标识符保持不变。由于表的所有索引都位于与表相同的表空间中,因此此值不一定唯一。An identifier for the tablespace where the index resides. 0 means the InnoDB system tablespace. Any other number represents a table created with a separate .ibd file in file-per-table mode. This identifier stays the same after a TRUNCATE TABLE statement. Because all indexes for a table reside in the same tablespace as the table, this value is not necessarily unique.

  • MERGE_THRESHOLD

    索引页的合并阈值。如果在删除行或通过更新操作缩短行时,索引页中的数据量低于MERGE_THRESHOLD值,InnoDB会尝试将该索引页与相邻的索引页合并。默认阈值为 50%。更多信息,请参见第 17.8.11 节,“配置索引页的合并阈值”。The merge threshold value for index pages. If the amount of data in an index page falls below the MERGE_THRESHOLD value when a row is deleted or when a row is shortened by an update operation, InnoDB attempts to merge the index page with the neighboring index page. The default threshold value is 50%. For more information, see Section 17.8.11, “Configuring the Merge Threshold for Index Pages”.

示例Example

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_INDEXES WHERE TABLE_ID = 34\G
*************************** 1. row ***************************
       INDEX_ID: 39
           NAME: GEN_CLUST_INDEX
       TABLE_ID: 34
           TYPE: 1
       N_FIELDS: 0
        PAGE_NO: 3
          SPACE: 23
MERGE_THRESHOLD: 50
*************************** 2. row ***************************
       INDEX_ID: 40
           NAME: i1
       TABLE_ID: 34
           TYPE: 0
       N_FIELDS: 1
        PAGE_NO: 4
          SPACE: 23
MERGE_THRESHOLD: 50

注意事项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.