6.19. IP Functions
ipprefix
(_ip_address, prefix_bits) → ipprefix- Returns the IP prefix of a given
ip_address
with subnet size ofprefix_bits
.ip_address
can be either of typeVARCHAR
or typeIPADDRESS
.
- SELECT ip_prefix(CAST('192.168.255.255' AS IPADDRESS), 9); -- {192.128.0.0/9}
- SELECT ip_prefix('2001:0db8:85a3:0001:0001:8a2e:0370:7334', 48); -- {2001:db8:85a3::/48}