SQL Reference
Network Type Functions
the {{ocient}} system supports these functions for ip and ipv4 data types ip casts the ipv4 data type to the ip data type the returned value is the ipv6 mapped ipv4 address syntax ip(ipv4 col) argument data type description ipv4 col char or ipv4 ip address in the ipv4 data type to cast example cast the ipv4 address 128 1 2 3 to the ipv6 mapped ipv4 address select ip(ipv4('128 1 2 3')); output ip(ipv4(('128 1 2 3'))) \ 128 1 2 3 fetched 1 row ipv4 returns the ipv4 portion of the ipv6 address 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 ipv6 mapped ip address in the ip data type to cast if the ipv6 address is not ipv4 compatible, ipv6 mapped, or nat64 prefixed, the cast returns an invalid data type conversion error example cast the ipv6 mapped ip address ffff 128 1 2 3 to the ipv4 data type return the ipv4 portion of the address 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 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 the function returns a boolean value ( true or false ) that indicates whether the conversion works from the specified ip address to the ipv4 address syntax is ipv4(ip col) argument data type description ip col ip specified ip address for conversion to an ipv4 address example determine whether the fffe 128 1 2 3 string is a valid ipv4 address use the ip function to cast the string as an ip address 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 the ip col argument syntax subnet(ip col, prefix size) argument data type description ip col ip or ipv4 the ip address for the prefix calculation prefix size integer the size of the subnet network prefix for ipv4 addresses, the size must be in the range \[0, 32], and for ip addresses, the size must be in the range \[0, 128] if the prefix exceeds these range values, the function returns an invalid argument error example calculate the prefix for the nat64 prefixed ip address 64\ ff9b 128 2 3 4 with prefix size 98 use the ip function to cast the string as an ip address 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 docid\ ogtviwl gtbgv0chhrh 3