zoukankan      html  css  js  c++  java
  • INET_ATON(expr)

    MySQL :: MySQL 8.0 Reference Manual :: 12.24 Miscellaneous Functions https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_inet-aton

    • INET_ATON(expr)

      Given the dotted-quad representation of an IPv4 network address as a string, returns an integer that represents the numeric value of the address in network byte order (big endian). INET_ATON() returns NULL if it does not understand its argument.

      mysql> SELECT INET_ATON('10.0.5.9');
              -> 167773449

      For this example, the return value is calculated as 10×2563 + 0×2562 + 5×256 + 9.

      INET_ATON() may or may not return a non-NULL result for short-form IP addresses (such as '127.1' as a representation of '127.0.0.1'). Because of this, INET_ATON()a should not be used for such addresses.

      Note

      To store values generated by INET_ATON(), use an INT UNSIGNED column rather than INT, which is signed. If you use a signed column, values corresponding to IP addresses for which the first octet is greater than 127 cannot be stored correctly. See Section 11.1.7, “Out-of-Range and Overflow Handling”.

    • INET_NTOA(expr)

      Given a numeric IPv4 network address in network byte order, returns the dotted-quad string representation of the address as a string in the connection character set. INET_NTOA() returns NULL if it does not understand its argument.

      mysql> SELECT INET_NTOA(167773449);
              -> '10.0.5.9'
    • INET_ATON(expr)

      Given the dotted-quad representation of an IPv4 network address as a string, returns an integer that represents the numeric value of the address in network byte order (big endian). INET_ATON() returns NULL if it does not understand its argument.

      mysql> SELECT INET_ATON('10.0.5.9');
              -> 167773449

      For this example, the return value is calculated as 10×2563 + 0×2562 + 5×256 + 9.

      INET_ATON() may or may not return a non-NULL result for short-form IP addresses (such as '127.1' as a representation of '127.0.0.1'). Because of this, INET_ATON()a should not be used for such addresses.

      Note

      To store values generated by INET_ATON(), use an INT UNSIGNED column rather than INT, which is signed. If you use a signed column, values corresponding to IP addresses for which the first octet is greater than 127 cannot be stored correctly. See Section 11.1.7, “Out-of-Range and Overflow Handling”.

    • INET_NTOA(expr)

      Given a numeric IPv4 network address in network byte order, returns the dotted-quad string representation of the address as a string in the connection character set. INET_NTOA() returns NULL if it does not understand its argument.

      mysql> SELECT INET_NTOA(167773449);
              -> '10.0.5.9'
  • 相关阅读:
    大数据内存模型(二级指针)
    多线程函数指针
    返回函数指针的函数
    动态分配二维数组指针
    俄罗斯方块学习笔记
    tailf
    tail
    cut
    split
    paste
  • 原文地址:https://www.cnblogs.com/rsapaper/p/15402642.html
Copyright © 2011-2022 走看看