Skip to main content

IP Address Functions

This page provides reference information for the IP address-related functions in Databend. These functions help convert between string and numeric representations of IP addresses.

IP Address Conversion Functions

FunctionDescriptionExample
INET_ATON / IPV4_STRING_TO_NUMConverts an IPv4 address string to a 32-bit integerINET_ATON('192.168.1.1')3232235777
INET_NTOA / IPV4_NUM_TO_STRINGConverts a 32-bit integer to an IPv4 address stringINET_NTOA(3232235777)'192.168.1.1'

Safe IP Address Conversion Functions

These functions handle invalid inputs gracefully by returning NULL instead of raising an error.

FunctionDescriptionExample
TRY_INET_ATON / TRY_IPV4_STRING_TO_NUMSafely converts an IPv4 address string to a 32-bit integerTRY_INET_ATON('invalid')NULL
TRY_INET_NTOA / TRY_IPV4_NUM_TO_STRINGSafely converts a 32-bit integer to an IPv4 address stringTRY_INET_NTOA(-1)NULL
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today