IP and IPV4 data types.
IP
Casts theIPV4 data type to the IP data type. The returned value is the IPv6-mapped IPv4 address.
Syntax
SQL
Example
Cast the IPv4 address
128.1.2.3 to the IPv6-mapped IPv4 address.
SQL
Text
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
SQL
Example
Cast the IPv6-mapped IP address
::ffff:128.1.2.3 to the IPV4 data type. Return the IPv4 portion of the address.
SQL
Text
IS_IPV4
TheIS_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
true or false) that indicates whether the conversion works from the specified IP address to the IPv4 address.
Syntax
SQL
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.
SQL
Text
SUBNET
TheSUBNET 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
SQL
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.
SQL
Text

