For a string argument str, HEX() returns a hexadecimal string representation of str where each character in str is converted to two hexadecimal digits. The inverse of this operation is performed by the UNHEX() function.
For a numeric argument N, HEX() returns a hexadecimal string representation of the value of N treated as a longlong (BIGINT) number. This is equivalent to CONV(. The inverse of this operation is performed by N,10,16)CONV(HEX(.N),16,10)
mysql>SELECT 0x616263, HEX('abc'), UNHEX(HEX('abc'));-> 'abc', 616263, 'abc' mysql>SELECT HEX(255), CONV(HEX(255),16,10);-> 'FF', 255
hex會把字符串中的每一個字符轉換成兩個16進制數
* INET_ATON(expr)
給出一個作為字符串的網絡地址的"點地址"(如127.0.0.1)表示,返回一個代表該地址數值的整數。地址可以是4或8比特地址。
mysql> SELECT INET_ATON('209.207.224.40');
-> 3520061480
產生的數字總是按照網絡字節順序。如上面的例子,數字按照 209×2563 + 207×2562 + 224×256 + 40 進行計算。
INET_ATON() 也能理解短格式 IP 地址:
mysql> SELECT INET_ATON('127.0.0.1'), INET_ATON('127.1');
-> 2130706433, 2130706433
注 釋: 在存儲由INET_ATON() 產生的值時,推薦你使用 INT UNSIGNED 列。假如你使用 (帶符號) INT列, 則相應的第一個八位組大於127的IP 地址值會被截至 2147483647 (即, INET_ATON('127.255.255.255') 所返回的值)。請參見11.2節,“數值類型”。
* INET_NTOA(expr)
給定一個數字網絡地址 (4 或 8 比特),返回作為字符串的該地址的電地址表示。
*
mysql> SELECT INET_NTOA(3520061480);
-> '209.207.224.40'
