top of page
CerebroSQL

INET6_NTOA

База данных: MySQL

68747470733a2f2f7374796c65732e7265646469746d656469612e636f6d2f74355f32716d366b2f7374796c65

Syntax:
INET6_NTOA(expr)

Given an IPv6 or IPv4 network address represented in numeric form as a
binary string, returns the string representation of the address as a
string in the connection character set. If the argument is not a valid
address, INET6_NTOA() returns NULL.

INET6_NTOA() has these properties:

o It does not use operating system functions to perform conversions,
thus the output string is platform independent.

o The return string has a maximum length of 39 (4 x 8 + 7). Given this
statement:

CREATE TABLE t AS SELECT INET6_NTOA(expr) AS c1;

The resulting table would have this definition:

CREATE TABLE t (c1 VARCHAR(39) CHARACTER SET utf8 DEFAULT NULL);

o The return string uses lowercase letters for IPv6 addresses.

URL: https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html

Example

mysql> SELECT INET6_NTOA(INET6_ATON('fdfe::5a55:caff:fefa:9089'));
-> 'fdfe::5a55:caff:fefa:9089'
mysql> SELECT INET6_NTOA(INET6_ATON('10.0.5.9'));
-> '10.0.5.9'

mysql> SELECT INET6_NTOA(UNHEX('FDFE0000000000005A55CAFFFEFA9089'));
-> 'fdfe::5a55:caff:fefa:9089'
mysql> SELECT INET6_NTOA(UNHEX('0A000509'));
-> '10.0.5.9'

bottom of page