Is BIGINT(8) the largest integer mysql can store?

前端 未结 5 1919
悲&欢浪女
悲&欢浪女 2020-12-09 14:50

I\'ve got some numbers that is now larger than INT can handle.

This is a bit embarassing, but I honestly don\'t know exactly what the BIGINT(8) means. Is the 8 in th

5条回答
  •  长情又很酷
    2020-12-09 15:30

    To store a 128-bit integer, you can use a BINARY(16).

    For 252:

    SELECT RIGHT(CONCAT(REPEAT("\0",16),UNHEX(CONV(252,10,16))),16);

    or equivalently:

    SELECT UNHEX(RIGHT(CONCAT(REPEAT("0",32),HEX(252)),32));

    (but MySQL integer calculations are 64-bit)

    See also the recent IPv6 functions INET6_ATON() and INET6_NTOA(), http://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_inet6-aton and how they use a VARBINARY(16).

提交回复
热议问题