SQL Reference
Network Type Functions
the {{ocient}} system supports these functions for ip and ipv4 data types ip the ipv4 data type is castable to ip the returned value is the ipv6 mapped ipv4 address, which has the form ffff\ x x x x syntax ip(ipv4 col) argument data type description ipv4 col ipv4 returns the ipv6 mapped ipv4 address example select ip(ipv4('128 1 2 3')); output ip(ipv4(('128 1 2 3'))) \ /128 1 2 3 fetched 1 row ipv4 you can only cast the ip data type to ipv4 if the ipv6 value has an ipv4 semantic equivalent the database can convert these ipv6 address formats to ipv4 ipv4 compatible ipv6 x x x x ipv6 mapped ipv4 ffff\ x x x x nat64 prefixed 64\ ff9b x x x x syntax ipv4(ip col) argument data type description ip col ip returns the ipv4 portion of the ipv6 address if the ipv6 address is not ipv4 compatible, ipv6 mapped, or nat64, the cast returns an invalid data type conversion error example select ipv4(ip(' ffff 128 1 2 3')); output ipv4(ip((' ffff 128 1 2 3'))) \ /128 1 2 3 fetched 1 row is ipv4 the is ipv4 boolean function tests whether the database can convert the ip value to the ipv4 data type the database can convert these ipv6 address formats to ipv4 ipv4 compatible ipv6 x x x x ipv6 mapped ipv4 ffff\ x x x x nat64 prefixed 64\ ff9b x x x x syntax is ipv4(ip col) argument data type description ip col ip denotes whether the database can convert the specified ip value to the ipv4 data type with return values true or false example select is ipv4(ip(' fffe 128 1 2 3')); output is ipv4 convertible(ip((' fffe 128 1 2 3'))) \ false fetched 1 row subnet the subnet function computes the prefix from an ip or ipv4 value and the size of the prefix the function returns a value of the same type as ip col syntax subnet(ip col, prefix size) argument data type description ip col ip , ipv4 the ip address from which to calculate the prefix prefix size integral the size of the subnet network prefix for ipv4 addresses, the size must be in \[0, 32], and for ip addresses, the size must be in \[0, 128] if the prefix exceeds these range values, the function returns an invalid argument error example select subnet(ip('64\ ff9b 128 2 3 4'), 98); output subnet(ip(('64\ ff9b 128 2 3 4')), (98)) \ /64\ ff9b 0 0 0 0 8000 0 fetched 1 row related links data types docid\ salunscyvkcxpgzh3m0hd