数值类型
-
TINYINT,大小 1bytes,有符号范畴为 -128~127,无符号范畴为 0~255
# 计算 (-2 ^ (8 * 1)) / 2 = -128 (2 ^ (8 * 1))/2 - 1 = 127 (2 ^ (8 * 1)) - 1 = 255
-
SMALLINT,大小 2bytes,有符号范畴为 -32768~32767,无符号范畴为 0~65535
# 计算 (-2 ^ (8 * 2)) / 2 = -32768 (2 ^ (8 * 2)) / 2 - 1 = 32767 (2 ^ (8 * 2)) - 1 = 65535
-
MEDIUMINT,大小 3bytes,有符号范畴为 -8388608~8388607,无符号范畴为 0~16777215
# 计算 (-2 ^ (8 * 3)) / 2 = -8388608 (2 ^ (8 * 3)) / 2 - 1= 8388607 (2 ^ (8 * 3)) - 1 = 16777215
-
INT,大小 4bytes,有符号范畴为 -2147483648~2147483647,无符号范畴为 0~4294967295
# 计算 (-2 ^ (8 * 4)) / 2 = -2147483648 (2 ^ (8 * 4)) / 2 - 1 = 2147483647 (2 ^ (8 * 4)) - 1 = 4294967295
-
BIGINT,大小 8bytes,有符号范畴为 -9223372036854775808~9223372036854775807,无符号范畴为 0~18446744073709551615
# 计算 (-2 ^ (8 * 8)) / 2 = -9223372036854775808 (2 ^ (8 * 8)) / 2 - 1 = 9223372036854775807 (2 ^ (8 * 8)) - 1 = 18446744073709551615