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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

28.4.9 INFORMATION_SCHEMA INNODB_COLUMNS 表28.4.9 The INFORMATION_SCHEMA INNODB_COLUMNS Table

INNODB_COLUMNS 表提供有关 InnoDB 表列的元数据。The INNODB_COLUMNS table provides metadata about InnoDB table columns.

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

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

  • TABLE_ID

    表示与该列关联的表的标识符;其值与 INNODB_TABLES.TABLE_ID 相同。An identifier representing the table associated with the column; the same value as INNODB_TABLES.TABLE_ID.

  • NAMENAME

    列的名称。这些名称可以是大写或小写,具体取决于lower_case_table_names 设置。列没有特殊的系统保留名称。The name of the column. These names can be uppercase or lowercase depending on the lower_case_table_names setting. There are no special system-reserved names for columns.

  • POS

    列在表中的顺序位置,从 0 开始,依次递增。当删除一个列时,其余列会重新排序,使序列没有空隙。虚拟生成列的POS值编码了列的序列号和顺序位置。更多信息,请参见第 28.4.29 节,“INFORMATION_SCHEMA INNODB_VIRTUAL 表”中POS列的描述。The ordinal position of the column within the table, starting from 0 and incrementing sequentially. When a column is dropped, the remaining columns are reordered so that the sequence has no gaps. The POS value for a virtual generated column encodes the column sequence number and ordinal position of the column. For more information, see the POS column description in Section 28.4.29, “The INFORMATION_SCHEMA INNODB_VIRTUAL Table”.

  • MTYPE

    代表“主类型”。列类型的数字标识符。1 = VARCHAR,2 = CHAR,3 = FIXBINARY,4 = BINARY,5 = BLOB,6 = INT,7 = SYS_CHILD,8 = SYS,9 = FLOAT,10 = DOUBLE,11 = DECIMAL,12 = VARMYSQL,13 = MYSQL,14 = GEOMETRY。Stands for “main type”. A numeric identifier for the column type. 1 = VARCHAR, 2 = CHAR, 3 = FIXBINARY, 4 = BINARY, 5 = BLOB, 6 = INT, 7 = SYS_CHILD, 8 = SYS, 9 = FLOAT, 10 = DOUBLE, 11 = DECIMAL, 12 = VARMYSQL, 13 = MYSQL, 14 = GEOMETRY.

  • PRTYPE

    InnoDB “精确类型”,一个二进制值,其中的位表示 MySQL 数据类型、字符集编码和可空性。The InnoDB “precise type”, a binary value with bits representing MySQL data type, character set code, and nullability.

  • LEN

    列长度,例如 INT 为 4,BIGINT 为 8。对于多字节字符集中的字符列,这个长度值是表示类似 VARCHAR(N) 定义所需的最大字节数;也就是说,根据字符编码,它可能是 2*N、3*N 等等。The column length, for example 4 for INT and 8 for BIGINT. For character columns in multibyte character sets, this length value is the maximum length in bytes needed to represent a definition such as VARCHAR(N); that is, it might be 2*N, 3*N, and so on depending on the character encoding.

  • HAS_DEFAULT

    一个布尔值,用于指示一个使用 ALTER TABLE ... ADD COLUMN 并带有 ALGORITHM=INSTANT 立即添加的列是否有默认值。所有立即添加的列都有默认值,因此该列用于指示该列是否是立即添加的。A boolean value indicating whether a column that was added instantly using ALTER TABLE ... ADD COLUMN with ALGORITHM=INSTANT has a default value. All columns added instantly have a default value, which makes this column an indicator of whether the column was added instantly.

  • DEFAULT_VALUE

    使用 ALTER TABLE ... ADD COLUMN 并带 ALGORITHM=INSTANT 即时添加列的初始默认值。如果默认值为 NULL 或未指定,则该列显示 NULL。显式指定的非 NULL 默认值以内部二进制格式显示。随后的列默认值修改不会更改该列报告的值。The initial default value of a column that was added instantly using ALTER TABLE ... ADD COLUMN with ALGORITHM=INSTANT. If the default value is NULL or was not specified, this column reports NULL. An explicitly specified non-NULL default value is shown in an internal binary format. Subsequent modifications of the column default value do not change the value reported by this column.

示例Example

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_COLUMNS where TABLE_ID = 71\G
*************************** 1. row ***************************
     TABLE_ID: 71
         NAME: col1
          POS: 0
        MTYPE: 6
       PRTYPE: 1027
          LEN: 4
  HAS_DEFAULT: 0
DEFAULT_VALUE: NULL
*************************** 2. row ***************************
     TABLE_ID: 71
         NAME: col2
          POS: 1
        MTYPE: 2
       PRTYPE: 524542
          LEN: 10
  HAS_DEFAULT: 0
DEFAULT_VALUE: NULL
*************************** 3. row ***************************
     TABLE_ID: 71
         NAME: col3
          POS: 2
        MTYPE: 1
       PRTYPE: 524303
          LEN: 10
  HAS_DEFAULT: 0
DEFAULT_VALUE: NULL

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