Mysql数据类型

数值类型

  • 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

你可能感兴趣的:(mysql)