MySQL tinyint/smallint/int/bigint

MySQL tinyint/smallint/int/bigint取值范围


数据类型 存储大小 取值范围 最大存储位数
tinyint 1 字节 signed : -128 ~ 127 3位
unsigned : 0 ~ 255 3位
smallint 2 字节 signed : -32768 ~ 32767 5位
unsigned : 0 ~ 65535 5位
int 4 字节 signed : -2147483648 ~ 2147483647 10位
unsigned : 0 ~ 4294967295 10位
bigint 8 字节 signed : -9223372036854775808 ~ 9223372036854775807 19位
unsigned : 0 ~ 18446744073709551615 20位

    mysql> help tinyint;

    A very small integer. 
    The signed range is -128 to 127. 
    The unsigned range is 0 to 255.

    mysql> help smallint;

    A small integer. 
    The signed range is -32768 to 32767. 
    The unsigned range is 0 to 65535.

    mysql> help int;

    A normal-size integer. 
    The signed range is -2147483648 to 2147483647.
    The unsigned range is 0 to 4294967295.

    mysql> help bigint;

    A large integer. 
    The signed range is -9223372036854775808 to 9223372036854775807. 
    The unsigned range is 0 to 18446744073709551615.

你可能感兴趣的:(GavinLau,-,MySQL)