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 byInnoDBhave consistent names but the index names are not necessarily unique. Examples:PRIMARYfor a primary key index,GEN_CLUST_INDEXfor the index representing a primary key when one is not specified, andID_IND,FOR_IND, andREF_INDfor foreign key constraints.TABLE_ID表示与索引相关联的表的标识符;此值与
INNODB_TABLES.TABLE_ID相同。An identifier representing the table associated with the index; the same value asINNODB_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. ForGEN_CLUST_INDEXindexes, 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, thePAGE_NOcolumn 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 theInnoDBsystem tablespace. Any other number represents a table created with a separate.ibdfile in file-per-table mode. This identifier stays the same after aTRUNCATE TABLEstatement. 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 theMERGE_THRESHOLDvalue when a row is deleted or when a row is shortened by an update operation,InnoDBattempts 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 thePROCESSprivilege to query this table.使用
INFORMATION_SCHEMACOLUMNS表或SHOW COLUMNS语句查看关于此表列的更多信息,包括数据类型和默认值。Use theINFORMATION_SCHEMACOLUMNStable or theSHOW COLUMNSstatement to view additional information about the columns of this table, including data types and default values.