Collections:
INET6_NTOA() - IPv6 Address Number to String
How to convert an IPv6 address from number format to string using the INET6_NTOA() function?
✍: FYIcenter.com
INET6_NTOA(int) is a MySQL built-in function that
converts an IPv6 address from number format to string.
For example:
SET @ipv6 = UNHEX('FDFE0000000000005A55CAFFFEFA9089');
SELECT HEX(@ipv6), INET6_NTOA(@ipv6);
-- +----------------------------------+---------------------------+
-- | HEX(@ipv6) | INET6_NTOA(@ipv6) |
-- +----------------------------------+---------------------------+
-- | FDFE0000000000005A55CAFFFEFA9089 | fdfe::5a55:caff:fefa:9089 |
-- +----------------------------------+---------------------------+
INET6_NTOA also works on IPv4 addresses. For example:
SET @ipv4 = UNHEX('0A000509');
SELECT HEX(@ipv4), INET6_NTOA(@ipv4);
-- +------------+-------------------+
-- | HEX(@ipv4) | INET6_NTOA(@ipv4) |
-- +------------+-------------------+
-- | 0A000509 | 10.0.5.9 |
-- +------------+-------------------+
Reference information of the INET6_NTOA() function:
INET6_NTOA(int): ip Converts an IPv6 address from number format to string. Arguments, return value and availability: int: Required. The IPv6 address in number format. ip: Return value. The IPv6 address as a string. Available since MySQL 4.0.
Related MySQL functions:
⇒ IS_FREE_LOCK() - Checking Lock Status
⇐ INET6_ATON() - IPv6 Address String to Number
2023-12-17, 1027🔥, 0💬
Popular Posts:
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want t...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Convert Numeric Expression Data Types using the CAST() Function in SQL Server Transact-SQL? I...
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...