Collections:
INET6_ATON() - IPv6 Address String to Number
How to convert an IPv6 address from string format to number using the INET6_ATON() function?
✍: FYIcenter.com
INET6_ATON(ip) is a MySQL built-in function that
converts an IPv6 address from string format to number.
But an IPv6 number is too big to be represented in decimal digits.
So it is stored as a byte sequence, and
you need to convert it in hexadecimal digits to see it.
For example:
SELECT INET6_ATON('fdfe::5a55:caff:fefa:9089'),
HEX(INET6_ATON('fdfe::5a55:caff:fefa:9089'));
-- +-----------------------------------------+----------------------------------------------+
-- | INET6_ATON('fdfe::5a55:caff:fefa:9089') | HEX(INET6_ATON('fdfe::5a55:caff:fefa:9089')) |
-- +-----------------------------------------+----------------------------------------------+
-- | ?? ZU?????? | FDFE0000000000005A55CAFFFEFA9089 |
-- +-----------------------------------------+----------------------------------------------+
INET6_NTOA also works on IPv4 addresses. For example:
SELECT INET6_ATON('10.0.5.9'), HEX(INET6_ATON('10.0.5.9'));
-- +------------------------+-----------------------------+
-- | INET6_ATON('10.0.5.9') | HEX(INET6_ATON('10.0.5.9')) |
-- +------------------------+-----------------------------+
-- | | 0A000509 |
-- +------------------------+-----------------------------+
Reference information of the INET6_ATON() function:
INET6_ATON(ip): bytes Converts an IPv6 address from string format to number. Arguments, return value and availability: ip: Required. The IPv6 address in string format. bytes: Return value. The IPv6 address as a number in bytes. Available since MySQL 4.0.
Related MySQL functions:
⇒ INET6_NTOA() - IPv6 Address Number to String
⇐ INET_NTOA() - IP Address Number to String
2023-12-19, 915🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions on Storage Engines: MyISAM, InnoDB and BDB in My...
How to download and install SQL Server 2005 Sample Scripts in SQL Server? If you want to learn from ...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
How To Look at the Current SQL*Plus System Settings in Oracle? If you want to see the current values...