数值类型数据
SERIAL
is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
.
SERIAL
是BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
的别名。
这句话什么意思呢?先让我们执行下图中的 SQL 语句
结果
SERIAL DEFAULT VALUE
in the definition of an integer column is an alias for NOT NULL AUTO_INCREMENT UNIQUE
.
SERIAL DEFAULT VALUE
在定义整数column
是NOT NULL AUTO_INCREMENT UNIQUE
的别名。
这句话什么意思呢?我们执行下图中的 SQL 语句
结果
以此推类,定义整数类型的column
时,SERIAL DEFAULT VALUE
可以简写NOT NULL AUTO_INCREMENT UNIQUE
[]
表示 [可选]
数据类型名称 | 原文描述 | 中文描述 |
---|---|---|
BIT [(M)] |
A bit-value type. M indicates the number of bits per value, from 1 to 64 . The default is 1 if M is omitted. |
比特值类型。_M _ 表示数字 1 ~ 64 。省略 M 则默认值为 1 。 |
TINYINT [(M)] [UNSIGNED] [ZEROFILL] |
A very small integer. The signed range is -128 to 127 . The unsigned range is 0 to 255 . |
非常小的整数。有符号的范围是 -128 ~ 127 。无符号的范围是 0 ~ 255 。 |
BOOL , BOOLEAN |
These types are synonyms for TINYINT(1) . A value of zero is considered false.Nonzero values are considered true, However, the values TRUE and FALSE are merely aliases for 1 and 0 , respectively. |
类型和 TINYINT(1) 相同。值为零则为 false。非零为 true,但是 TRUE 和 FALSE 分别只是 1 和 0 的别名。 |
SMALLINT [(M)] [UNSIGNED] [ZEROFILL] |
A small integer. The signed range is -32,768 to 32,767 . The unsigned range is 0 to 65,535 . |
很小的整数。有符号的范围是 -32,768 ~ 32,767 。无符号的范围是 0 ~ 65,535 。 |
MEDIUMINT [(M)] |
A medium-sized integer. The signed range is -8,388,608 to 8,388,607 . The unsigned range is 0 to 16,777,215 . |
中等大小的整数。有符号的范围是 -8,388,608 ~ 8,388,607 。 |
INT [(M)] [UNSIGNED] [ZEROFILL] |
A normal-size integer. The signed range is -2,147,483,648 to 2,147,483,647 . The unsigned range is 0 to 4,294,967,295 . |
正常大小的整数。有符号的范围是 -2,147,483,648 ~ 2,147,483,647 。无符号的范围是 0 ~ 4,294,967,295 。 |
INTEGER [(M)] [UNSIGNED] [ZEROFILL] |
This type is a synonym for INT . |
和 INT 类型相同。 |
BIGINT [(M)] [UNSIGNED] [ZEROFILL] |
A large integer. The signed range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 . The unsigned range is 0 to 18,446,744,073,709,551,615 . |
大的整数。有符号的范围是 -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 。无符号范围是 0 ~ 18,446,744,073,709,551,615 。 |
DECIMAL [(M[, D])] [UNSIGNED] [ZEROFILL] |
A packed “exact” fixed-point number. M is the total number of digits (the precision) and D is the number of digits after the decimal point (the scale). The decimal point and (for negative numbers) the - sign are not counted in M . If D is 0 , values have no decimal point or fractional part. The maximum number of digits ( M ) for DECIMAL is 65 . The maximum number of supported decimals ( D ) is 30 . If D is omitted, the default is 0 . If M is omitted, the default is 10 . UNSIGNED , if specified, disallows negative values. All basic calculations ( +, -, *, / ) with DECIMAL columns are done with a precision of 65 digits. |
已封装好的“精确”定点数。_M _ 是总位数(精度),_D _ 是小数点后面的位数(小数位数)。 . 和 - 符号不计入 M 。如果 D 为0 ,值就没有小数点或小数部分。DECIMAL 的最大位数 ( M ) 为 65 。D 最大支持小数是 30 。如果 省略 D ,默认为 0 。省略 M 则默认为10 。如果指定 UNSIGNED ,就不允许负数。DECIMAL 的所有基本计算(加、减、乘、除 )都以 65 位精度完成。 |
DEC [(M[, D])] [UNSIGNED] [ZEROFILL] , NUMERIC[(M[, D])] [UNSIGNED] [ZEROFILL] , FIXED [(M[, D])] [UNSIGNED] [ZEROFILL] |
These types are synonyms for DECIMAL . The FIXED synonym is available for compatibility with other database systems. |
类型和 DECIMAL 相同。FIXED 用于兼容其他数据库系统。 |
FLOAT [(M,D)] [UNSIGNED] [ZEROFILL] |
A small (single-precision) floating-point number. Permissible values are -3.402823466E+38 to -1.175494351E-38 ,0 , and 1.175494351E-38 to 3.402823466E+38 . These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits permitted by the hardware. A single-precision floating-point number is accurate to approximately 7 decimal places. FLOAT [(M,D)] is a nonstandard MySQL extension. UNSIGNED , if specified, disallows negative values.Using FLOAT might give you some unexpected problems because all calculations in MySQL are done with double precision. |
很小(单精度)的浮点数。允许的值是 -3.402823466E+38 ~ -1.175494351E-38 ,0 ,1.175494351E-38 ~ 3.402823466E+38 。这些是理论的限制,基于 IEEE 标准。实际范围比这个可能更小一些,取决于您的硬件或操作系统。_M _ 是总位数,_D _ 是小数点后面的位数。如省略 M 和 D ,值将存在硬件允许的范围内。单精度浮点数精确到大约 7 位小数。FLOAT 是一个非标准的 MySQL 扩展。如指定UNSIGNED ,不允许负值。使用 FLOAT 可能会给您带来意料之外的问题,因为在 Mysql 中所有计算都通过双精度完成。 |
FLOAT (p) [UNSIGNED] [ZEROFILL] |
A floating-point number. p represents the precision in bits, but MySQL uses this value only to determine whether to use FLOAT or DOUBLE for the resulting data type. If p is from 0 to 24 , the data type becomes FLOAT with no M or *D *values. If p is from 25 to 53 , the data type becomes DOUBLE with no M or D values. The range of the resulting column is the same as for the single-precision FLOAT or double-precision DOUBLE data types described earlier in this section. FLOAT (p) syntax is provided for ODBC compatibility. |
浮点数。p 表示以位为单位的精度,但 MySQL 仅使用此值来确定结果数据类型是使用 FLOAT 还是 DOUBLE 。如果 p 是从 0 ~ 24 ,数据类型变成 FLOAT 且没有 M 或 D 值。如果 p 是从 25 ~ 53 ,数据类型变成 DOUBLE 且没有 M 或 D 值。结果 column 的范围与本节之前描述的单精度 FLOAT 或双精度 DOUBLE 类型相同。FLOAT (p) 语法是为了 ODBC 提供兼容。 |
DOUBLE [(M,D)] [UNSIGNED] [ZEROFILL] |
A normal-size (double-precision) floating-point number. Permissible values are -1.7976931348623157E+308 to-2.2250738585072014E-308 , 0 , and 2.2250738585072014E-308 to 1.7976931348623157E+308 . These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system. M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits permitted by the hardware. A double-precision floating-point number is accurate to approximately 15 decimal places. DOUBLE is a nonstandard MySQL extension. UNSIGNED , if specified, disallows negative values. |
正常大小(双精度)浮点数。允许值是 -1.7976931348623157E+308 ~`-2.2250738585072014E-308 , 0,和 2.2250738585072014E-308to 1.7976931348623157E+308。这些是理论的限制,基于 IEEE 标准。实际范围比这个可能更小一些,取决于您的硬件或操作系统。_ M_ 是总位数,_ D_ 是小数点后面的位数。如省略 _ M_ 和 _ D_ ,值将存在硬件允许的范围内。双精度浮点数精确到大约 15 位小数。 DOUBLE 是一个非标准的 MySQL 扩展。如指定 UNSIGNED`,不允许负值。 |
DOUBLE PRECISION [(M,D)] [UNSIGNED] [ZEROFILL] , REAL [(M,D)] [UNSIGNED] [ZEROFILL] |
These types are synonyms for DOUBLE . Exception: If the REAL_AS_FLOAT SQL mode is enabled, REAL is a synonym for FLOAT rather than DOUBLE . |
类型和 DOUBLE 相同。例外:如果启用了 REAL_AS_FLOAT SQL 模式,REAL 是 FLOAT 而不是 DOUBLE 。 |
日期和时间类型数据
数据类型名称 | 原文描述 | 中文描述 |
---|---|---|
DATE |
A date. The supported range is '1000-01-01' to '9999-12-31' . MySQL displays DATE values in 'YYYY-MM-DD' format, but permits assignment of values to DATE columns using either strings or numbers. |
日期。支持范围是 '1000-01-01' ~ '9999-12-31' 。Mysql 用 'YYYY-MM-DD' 格式显示 DATE 值,但允许使用字符串或数字分配给 DATE column 。 |
DATETIME [(fsp)] |
A date and time combination. The supported range is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999' . MySQL displays DATETIME values in 'YYYY-MM-DD hh:mm:ss[.fraction]' format, but permits assignment of values to DATETIME columns using either strings or numbers. An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0 . Automatic initialization and updating to the current date and time for DATETIME columns can be specified using DEFAULT and ON UPDATE column definition clauses, as described in Section 11.3.5, “Automatic Initialization and Updating for TIMESTAMP and DATETIME ”. |
日期和时间组合。支持范围是 '1000-01-01 00:00:00.000000' ~ '9999-12-31 23:59:59.999999' 。Mysql 用 'YYYY-MM-DD hh:mm:ss[.fraction]' 格式显示 DATETIME 值,但允许使用字符串或数字分配给 DATETIME column 。可选值 fsp ,从范围 0 ~ 6 中给定,用于指定小数秒精度。0 表示没有小数部分。如果省略,默认精度是 0 。指定当前日期和时间自动初始化和更新使用 DEFAULT 和 ON UPDATE column 定义条款,已描述在 11.3.5 部分,“自动初始化和更新 TIMESTAMP 和 DATETIME ”。 |
TIMESTAMP [(fsp)] |
A timestamp. The range is '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC. TIMESTAMP values are stored as the number of seconds since the epoch ('1970-01-01 00:00:00' UTC). A TIMESTAMP cannot represent the value '1970-01-01 00:00:00' because that is equivalent to 0 seconds from the epoch and the value 0 is reserved for representing '0000-00-00 00:00:00' , the “zero” TIMESTAMP value. An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0 . The way the server handles TIMESTAMP definitions depends on the value of the explicit_defaults_for_timestamp system variable (see Section 5.1.7, “Server System Variables”). If explicit_defaults_for_timestamp is enabled, there is no automatic assignment of the DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes to any TIMESTAMP column. They must be included explicitly in the column definition. Also, any TIMESTAMP not explicitly declared as NOT NULL permits NULL values. If explicit_defaults_for_timestamp is disabled, the server handles TIMESTAMP as follows: Unless specified otherwise, the first TIMESTAMP column in a table is defined to be automatically set to the date and time of the most recent modification if not explicitly assigned a value. This makes TIMESTAMP useful for recording the timestamp of an INSERT or UPDATE operation. You can also set any TIMESTAMP column to the current date and time by assigning it a NULL value, unless it has been defined with the NULL attribute to permit NULL values. Automatic initialization and updating to the current date and time can be specified using DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP column definition clauses. By default, the first TIMESTAMP column has these properties, as previously noted. However, any TIMESTAMP column in a table can be defined to have these properties. |
时间戳。范围是 '1970-01-01 00:00:01.000000' UTC ~ '2038-01-19 03:14:07.999999' UTC。TIMESTAMP 值存储的是纪元以来的秒数('1970-01-01 00:00:00' UTC)。TIMESTAMP 不能表示值 1970-01-01 00:00:00 ,因为相当于距纪元 0 秒,而值 0 保留用于表示 0000-00-00 00:00:00 ,即 “零” TIMESTAMP 值。可选值 fsp ,从范围 0 ~ 6 中给定,用于指定小数秒精度。0 表示没有小数部分。如果省略,默认精度是 0 。服务器处理 TIMESTAMP 定于的方式取决于系统变量值 explicit_defaults_for_timestamp (见 5.1.7 部分,“服务器系统变量”)。如果启用 explicit_defaults_for_timestamp ,则不会自动分配 CURRENT_TIMESTAMP 或 ON UPDATE CURRENT_TIMESTAMP 属性到任何 TIMESTAMP column 。它们必须明确包含在 column 定义中。还有,任何 TIMESTAMP 未被明确声明为 NOT NULL 允许 NULL 值。如果禁用 explicit_defaults_for_timestamp ,服务器处理 TIMESTAMP 如下:除非指定其他的,否则表中首个 TIMESTAMP column 会定义为自动设置日期和时间,如果没有明确分配值的话。这使记录时间戳进行 INSERT 或 UPDATE 操作有用。你还能设置任何 TINESTAMP column ,对当前日期和时间分配一个 NULL 值,除非它已定义 NULL 属性来允许 NULL 值。能对指定使用 DEFAULT CURRENT_TIMESTAMP 和 ON UPDATE CURRENT_TIMESTAMP column 的定义条款,自动初始化和更新当前日期和时间。默认情况,首个 TIMESTAMP column 有这些属性,正如之前提到的。然而,任何 TIMESTAMP column 在表中都可定义这些属性。 |
TIME [(fsp)] |
A time. The range is '-838:59:59.000000' to '838:59:59.000000' . MySQL displays TIME values in 'hh:mm:ss[.fraction]' format, but permits assignment of values to TIME columns using either strings or numbers. An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0 . |
时间。范围是 '-838:59:59.000000' ~ '838:59:59.000000' 。MySQL 在 'hh:mm:ss[.fraction]' 格式中显示 TIME ,但是允许使用字符串或数字进行分配 TIME column 的值。可选值 fsp ,从范围 0 ~ 6 中给定,用于指定小数秒精度。0 表示没有小数部分。如果省略,默认精度是 0 。 |
YEAR [(4)] |
A year in four-digit format. MySQL displays YEAR values in YYYY format, but permits assignment of values to YEAR columns using either strings or numbers. Values display as 1901 to 2155 , and 0000 . For additional information about YEAR display format and interpretation of input values, see Section 11.3.3, “The YEAR Type”. |
四位数格式的年份。MySQL 在 YYYY 格式中显示 YEAR 的值,但是允许使用字符串或数字进行分配 YEAR column 的值。值从 1901 ~ 2155 ,和 0000 作为显示。关于 YEAR 显示格式解释输入值的附加信息,见 11.3.3 部分,“年份类型” |
字符串类型数据
数据类型名称 | 原文描述 | 中文描述 |
---|---|---|
[NATIONAL] CHAR [(M)] [CHARACTER SET charset_name] [COLLATE collation_name] |
A fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255 . If M is omitted, the length is 1 . CHAR is shorthand for CHARACTER . NATIONAL CHAR (or its equivalent short form, NCHAR ) is the standard SQL way to define that a CHAR column should use some predefined character set. MySQL uses utf8 as this predefined character set. Section 10.3.7, “The National Character Set”. The CHAR BYTE data type is an alias for the BINARY data type. This is a compatibility feature. MySQL permits you to create a column of type CHAR(0) . This is useful primarily when you have to be compliant with old applications that depend on the existence of a column but that do not actually use its value. CHAR(0) is also quite nice when you need a column that can take only two values: A column that is defined as CHAR(0) NULL occupies only one bit and can take only the values NULL and '' (the empty string). |
定长字符串,存储时总是右填充空格到指定长度。_M _ 表示在字符中列长度。_M _ 的范围是 0 ~ 255 。如果 M 省略,长度为 1 。CHAR 是 CHARACTER 的简写。NATIONAL CHAR (或它的简短形式,NCHAR )是 SQL 标准定义方法,CHAR 列应使用一些预定义字符集。MySQL 使用 utf8 作为预定义字符集。10.3.7 部分,“国家字符集”。CHAR BYTE 数据类型是 BINARY 数据类型的别名。这是兼容特性。MySQL 允许你创建 CHAR(0) 类型的列。这主要在你要遵守旧应用依赖于所在列,但并不使用它的值时很有用。CHAR(0) 也相当微妙,当你需要列只能取两个值时:列被定义为 CHAR(0) NULL 只占一位,且只取值 NULL 和 '' (空字符串)。 |
[NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name] |
A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535 . The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters. See Section C.10.4, “Limits on Table Column Count and Row Size”. MySQL stores VARCHAR values as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A VARCHAR column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes. VARCHAR is shorthand for CHARACTER VARYING . NATIONAL VARCHAR is the standard SQL way to define that a VARCHAR column should use some predefined character set. MySQL uses utf8 as this predefined character set. Section 10.3.7, “The National Character Set”. NVARCHAR is shorthand for NATIONAL VARCHAR . |
变长字符串。_M _ 表示在字符中表示列最大长度。_M _ 范围是 0 ~ 65,535 。VARCHAR 最大有效长度取决于最大行大小(65,535 字节,分享于各列之间)和使用的字符集。例如,utf8 字符每字符最多需要三字节,所以使用 utf8 字符集的 VARCHAR 列最大能声明到 21,844 字符。见 C.10.4 部分,“ 表列数和行大小的限制”。MySQL 存储 VARCHAR 时,值为 1 个字节或 2 个字节长度前缀加上数据。长度前缀表示值中字节数。如果值不需要超过 255 字节,VARCHAR 列使用一个字节长度,如果值需要超过 255 字节,则用两个字节长度。VARCHAR 是 CHARACTER VARYING 的简短形式。NATIONAL VARCHAR 是 SQL 标准定义方法,VARCHAR 列应使用一些预定义字符集。MySQL 使用 utf8 作为预定义字符集。10.3.7 部分,“国家字符集”。NVARCHAR 是 NATIONAL VARCHAR 的简短形式。 |
BINARY [(M)] |
The BINARY type is similar to the CHAR type, but stores binary byte strings rather than nonbinary character strings. An optional length M represents the column length in bytes. If omitted, M defaults to 1 . |
BINARY 类型类似于 CHAR 类型,但存储的是二进制字节字符串并不是非二进制字符串。可选长度 M 表示列中的字节长度。如果省略,_M _ 默认为 1 。 |
VARBINARY( M ) |
The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than nonbinary character strings. M represents the maximum column length in bytes. |
VARBINARY 类型类似于 VARCHAR 类型,但存储的是二进制字节字符串并不是非二进制字符串。_M _ 表示列中的最大字节长度。 |
TINYBLOB |
A BLOB column with a maximum length of 255 (2^8^ − 1) bytes. Each TINYBLOB value is stored using a 1-byte length prefix that indicates the number of bytes in the value. |
BLOB 列最大字节长度 255 (2^8^ - 1)。每个 TINYBLOB 值用 1 字节长度储存前缀,表示值中的字节数。 |
TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name] |
A TEXT column with a maximum length of 255 (2^8^ − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TINYTEXT value is stored using a 1-byte length prefix that indicates the number of bytes in the value. |
TEXT 列最大字符长度 255 (2^8^ - 1)。如果值包含多字节字符,则最大有效长度较少。每个 TINYTEXT 值用 1 字节长度前缀存储,来表示值中的字节数 |
BLOB [(M)] |
A BLOB column with a maximum length of 65,535 (2^16^ − 1) bytes. Each BLOB value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest BLOB type large enough to hold values M bytes long. |
BLOB 列最大字节长度 65,535 (2^16^ - 1)。每个 BLOB 值使用 2 字节长度保存前缀,来表示值中的字节数。可以给这个类型可选长度 M 。如果这样做了,MySQL 创建该列作为最小 BLOB 类型,最大能保存到 M 字符长的值。 |
TEXT [(M)] [CHARACTER SET charset_name] [COLLATE collation_name] |
A TEXT column with a maximum length of 65,535 (2^16^ − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TEXT value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long. |
TEXT 列最大字符长度 65,535 (2^16^ - 1)。如果值包含多字节字符,则最大有效长度较少。每个 TEXT 值使用 2 字节长度存储前缀,表示值中字节数。可给这个类型可选长度 M 。如果这样做了,MySQL 创建该列作为最小 TEXT 类型,最大能保存到 M 字符长的值。 |
MEDIUMBLOB |
A BLOB column with a maximum length of 16,777,215 (2^24^ − 1) bytes. Each MEDIUMBLOB value is stored using a 3-byte length prefix that indicates the number of bytes in the value. |
BLOB 列最大字节长度 16,777,215 (2^24^ - 1)。每个 MEDIUMBLOB 值使用 3 字节长度存储前缀,来表示值中的字节数。 |
MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name] |
A TEXT column with a maximum length of 16,777,215 (2^24^ − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each MEDIUMTEXT value is stored using a 3-byte length prefix that indicates the number of bytes in the value. |
TEXT 列最大字符长度 16,777,215 (2^24^ - 1)。如果值包含多字节字符,最大有效长度较少。每个 MEDIUMTEXT 值使用 3 字节长度存储前缀,来表示值中的字节数。 |
LONGBLOB |
A BLOB column with a maximum length of 4,294,967,295 or 4GB (2^32^ − 1) bytes. The effective maximum length of LONGBLOB columns depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGBLOB value is stored using a 4-byte length prefix that indicates the number of bytes in the value. |
BLOB 列最大字节长度 4,294,967,295 或 4 GB。最大有效长度取决于 LONGBLOB 列在 客服端/服务端 协议中配置好的最大包大小和可用内存。每个 LONGBLOB 值使用 4 字节长度存储前缀,来表示值中的字节数。 |
LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name] |
A TEXT column with a maximum length of 4,294,967,295 or 4GB (2^32^ − 1) characters. The effective maximum length is less if the value contains multibyte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a 4-byte length prefix that indicates the number of bytes in the value. |
TEXT 列最大字符长度 4,294,967,295 或 4 GB。如果值包含多字节字符,最大有效长度较少。最大有效长度取决于 LONGTEXT 列在 客服端/服务端 协议中配置好的最大包大小和可用内存。每个 LONGTEXT 值使用 4 字节长度存储前缀,来表示值中的字节数。 |
ENUM('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name] |
An enumeration. A string object that can have only one value, chosen from the list of values 'value1' , 'value2' ,... , NULL or the special '' error value. ENUM values are represented internally as integers. An ENUM column can have a maximum of 65,535 distinct elements. (The practical limit is less than 3,000 .) A table can have no more than 255 unique element list definitions among its ENUM and SET columns considered as a group. For more information on these limits, see Section C.10.5, “Limits Imposed by .frm File Structure”. |
枚举。字符串对象,只能拥有一个值,从列表选择值 '值1' ,'值2' ,... ,NULL 或特殊错误值 '' 。ENUM 值作为整数在内部体现。ENUM 列最大能有 65,535 个不同元素。(实际限制小于 3,000 。)一个表不能拥有 255 个 唯一元素,列表定义中它的 ENUM 和 SET 列看作一组。这些限制更多说明,见 C.10.5 部分,“.frm 文件结构的限制”。 |
SET('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name] |
A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1' , 'value2' , ... SET values are represented internally as integers. A SET column can have a maximum of 64 distinct members. A table can have no more than 255 unique element list definitions among its ENUM and SET columns considered as a group. For more information on this limit, see Section C.10.5, “Limits Imposed by .frm File Structure”. |
集合。字符串对象,拥有零或很多值,每个必须从列表值 '值1' ,'值2' ,... 中选择,SET 值作为整数在内部体现。SET 列最大拥有 64 不同成员。一个表不能拥有 255 个 唯一元素,列表定义中它的 ENUM 和 SET 列看作一组。限制的详情,见 C.10.5 部分,“.frm 文件结构的限制”。 |