Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql服务器中“年”数据类型如何仅占用1字节_Mysql - Fatal编程技术网

mysql服务器中“年”数据类型如何仅占用1字节

mysql服务器中“年”数据类型如何仅占用1字节,mysql,Mysql,在Mysql服务器中,数据类型范围为1000到9999。如果我们将9999转换为二进制,则需要2个字节,那么Mysql服务器如何将其存储在1个字节中?初始断言不正确 仅支持从1901年到2155年(含)的年份。相比之下,支持的年限从1000年到9999年不等 [可指定年份值]范围在1901到2155之间 只需一个字节即可存储此范围内的不同整数2155-1901+1=255。全年(限制为1901..2155)通过使用1900:year=1900+存储的年字节的隐式偏移量进行计算 MySQL还支持一

在Mysql服务器中,数据类型范围为1000到9999。如果我们将9999转换为二进制,则需要2个字节,那么Mysql服务器如何将其存储在1个字节中?初始断言不正确

仅支持从1901年到2155年(含)的年份。相比之下,支持的年限从1000年到9999年不等

[可指定年份值]范围在1901到2155之间

只需一个字节即可存储此范围内的不同整数2155-1901+1=255。全年(限制为1901..2155)通过使用1900:year=1900+存储的年字节的隐式偏移量进行计算

MySQL还支持一个无效的年份sentinel值0,显示为0000,这就是为什么不允许使用1900年

年份类型是用于表示年份值的1字节类型。它可以声明为YEAR2或YEAR4,以指定两个或四个字符的显示宽度。如果未指定宽度,则默认值为四个字符

YEAR4和YEAR2具有不同的显示格式,但具有相同的值范围

对于4位格式,MySQL以YYYY格式显示年份值,范围为1901到2155或0000

对于2位格式,MySQL只显示最后两位最低有效数字;例如,70 1970或2070或69 2069

可以以多种格式指定年份值:

String length           |Range
4-digit string          | '1901' to '2155'.
4-digit number          |1901 to 2155.
1- or 2-digit string    |'0' to '99'. Values in the ranges '0' to '69' and '70' to '99' are converted to YEAR values in the ranges 2000 to 2069 and 1970 to 1999.
1- or 2-digit number    |1 to 99. Values in the ranges 1 to 69 and 70 to 99 are converted to YEAR values in the ranges 2001 to 2069 and 1970 to 1999.