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 asINNODB_TABLES.TABLE_ID.NAMENAME列的名称。这些名称可以是大写或小写,具体取决于
lower_case_table_names设置。列没有特殊的系统保留名称。The name of the column. These names can be uppercase or lowercase depending on thelower_case_table_namessetting. 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. ThePOSvalue for a virtual generated column encodes the column sequence number and ordinal position of the column. For more information, see thePOScolumn 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.PRTYPEInnoDB“精确类型”,一个二进制值,其中的位表示 MySQL 数据类型、字符集编码和可空性。TheInnoDB“precise type”, a binary value with bits representing MySQL data type, character set code, and nullability.LEN列长度,例如
INT为 4,BIGINT为 8。对于多字节字符集中的字符列,这个长度值是表示类似VARCHAR(定义所需的最大字节数;也就是说,根据字符编码,它可能是N)2*、N3*等等。The column length, for example 4 forNINTand 8 forBIGINT. For character columns in multibyte character sets, this length value is the maximum length in bytes needed to represent a definition such asVARCHAR(; that is, it might beN)2*,N3*, and so on depending on the character encoding.NHAS_DEFAULT一个布尔值,用于指示一个使用
ALTER TABLE ... ADD COLUMN并带有ALGORITHM=INSTANT立即添加的列是否有默认值。所有立即添加的列都有默认值,因此该列用于指示该列是否是立即添加的。A boolean value indicating whether a column that was added instantly usingALTER TABLE ... ADD COLUMNwithALGORITHM=INSTANThas 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 usingALTER TABLE ... ADD COLUMNwithALGORITHM=INSTANT. If the default value isNULLor was not specified, this column reportsNULL. An explicitly specified non-NULLdefault 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 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.