Network Address TypeNetwork Address Type mk Sat, 01/14/2012 - 14:49
The SQL type inet describes IPv4 network addresses, such as
CREATE TABLE inet_example (address inet NOT NULL);
A valid IPv4 Network Address string has a specific syntax, see also IPv4 address.
You can use cast() and convert() functions to convert a valid inet string into an inet value.
select cast('192.168.1.5/24' as inet);
select convert('192.168.1.5/24', inet);
You can also use the inet casting prefix:
select inet '192.168.1.5/24';
The inet module contains a collection of functions and operators that operate on IPv4 addresses. The most relevant functions are the 'containment' functions that deal with subnet masks. The functionality of this module is greatly inspired by the PostgreSQL inet data type.
In future it should be extended to also support IPv6.