跳到主要内容

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
开始使用 Databend Cloud
低成本
快速分析
多种数据源
弹性扩展
注册