在mysql中int(11)的列的大小是多少?
和可以存储在这些列中的最大值?
在mysql中int(11)的列的大小是多少?
和可以存储在这些列中的最大值?
当前回答
在MySQL中,整数int(11)的大小为4字节,等于32位。
带符号的值是-2的32-1次方到0到2的32-1次方-1 = -2147483648到0到2147483647
无符号值是:0到2^32-1 = 0 ~ 4294967295
其他回答
根据这里,int(11)将占用4个字节的空间,即2^(31)= 2147483648 max值和-2147483648min值的32位空间。一位是符号。
不管指定的长度是多少,INT总是4个字节。
TINYINT = 1字节(8位) SMALLINT = 2字节(16位) MEDIUMINT = 3字节(24位) INT = 4字节(32位) BIGINT = 8字节(64位)。
长度只是指定在使用mysql命令行客户端选择数据时要填充多少字符。12345存储为int(3)将仍然显示为12345,但如果它存储为int(10),它仍然显示为12345,但您可以选择填充前五位数字。例如,如果您添加了ZEROFILL,它将显示为0000012345。
... 最大值将是2147483647(有符号)或4294967295(无符号)
我认为int(11)的最大值是4294967295
虽然这个答案不太可能出现,但我认为有必要进行以下澄清:
the (n) behind an integer data type in MySQL is specifying the display width the display width does NOT limit the length of the number returned from a query the display width DOES limit the number of zeroes filled for a zero filled column so the total number matches the display width (so long as the actual number does not exceed the display width, in which case the number is shown as is) the display width is also meant as a useful tool for developers to know what length the value should be padded to
A BIT OF DETAIL the display width is, apparently, intended to provide some metadata about how many zeros to display in a zero filled number. It does NOT actually limit the length of a number returned from a query if that number goes above the display width specified. To know what length/width is actually allowed for an integer data type in MySQL see the list & link: (types: TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT); So having said the above, you can expect the display width to have no affect on the results from a standard query, unless the columns are specified as ZEROFILL columns OR in the case the data is being pulled into an application & that application is collecting the display width to use for some other sort of padding.
主要参考资料:https://blogs.oracle.com/jsmyth/entry/what_does_the_11_mean
在MySQL中,整数int(11)的大小为4字节,等于32位。
带符号的值是-2的32-1次方到0到2的32-1次方-1 = -2147483648到0到2147483647
无符号值是:0到2^32-1 = 0 ~ 4294967295