ID EN
Miscellaneous Functions

INET6_NTOA(expr)

MySQL 8.4

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, or if it is NULL, INET6_NTOA() returns NULL.

Syntax

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

Examples

Example

INET6_NTOA() has these properties:

MYSQL
CREATE TABLE t AS SELECT INET6_NTOA(expr) AS c1;
Example 2

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

MYSQL
CREATE TABLE t (c1 VARCHAR(39) CHARACTER SET utf8mb3 DEFAULT NULL);
Example 3

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

MYSQL
SELECT INET6_NTOA(INET6_ATON('fdfe::5a55:caff:fefa:9089'));
'fdfe::5a55:caff:fefa:9089'
SELECT INET6_NTOA(INET6_ATON('10.0.5.9'));
'10.0.5.9'

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