INET_NTOA

Returns the dotted-quad representation of the address as a VARCHAR, given a network address as an integer in network byte order.

Behavior Type

Immutable

Syntax

INET_NTOA ( expression )

Parameters

expression

(INTEGER) is the network address to convert.

Notes

The following syntax converts an IPv4 address represented as integer I to a string A.

INET_NTOA converts I from host byte order to network byte order using htonl, and calls the Linux function inet_ntop.

=> INET_NTOA(INT8 I) -> VARCHAR A

If I is NULL, greater than 2^32 or negative, the result is NULL.

Examples

=> SELECT INET_NTOA(16909060); 
 inet_ntoa 
-----------
 1.2.3.4
(1 row)

=> SELECT INET_NTOA(03021962);  
 inet_ntoa  
-------------
 0.46.28.138
(1 row)

See Also