HelloToYou HelloToYou - 10 months ago 52
SQL Question

Which type has INET6_ATON? / Max length of INET6_ATON?

I wanted to know how to save an

result to MYSQL. So I've read the MYSQL-Help article and it says, I should use
. But now, with an
-Address it has the content
and I'm unable to get results using SQL. My idea was to use
, but in this case I don't know what's the maximum length of an

So: How to get MYSQL-results if the result is saved as
Or otherwise: What's the maximum length of an

I'm converting the IP-Addresses using this SQL-Statement:

SELECT HEX(INET6_ATON("FE80:0000:0000:0000:0202:B3FF:FE1E:8329"))

Thanks a lot.


Note that the human readable column below is for human consumption.

The inet6 column will contain out-of-range numbers should I say to make much sense to humans. Goobly goop, if you will.

create table myFriends
(   id int auto_increment primary key,
    friendlyName varchar(100) not null,
    inet6 binary(16) not null,
    humanReadable char(32) not null

insert myFriends (friendlyName,inet6,humanReadable) values 
('Kathy Higgins',INET6_ATON("FE80:0000:0000:0000:0202:B3FF:FE1E:8329"),HEX(INET6_ATON("FE80:0000:0000:0000:0202:B3FF:FE1E:8329")));

select * from myFriends;
| id | friendlyName  | inet6            | humanReadable                    |
|  1 | Kathy Higgins | ■Ç      ☻☻│ ■▲â) | FE800000000000000202B3FFFE1E8329 |

FE80 represents 2 bytes. FE 80. Hexadecimal. Each byte ranges from 00 to FF (255).

Check out my answer Here on different formats. Often nearly duplicate info is used in one table.