IP address

MonetDB supports following Internet Protocol address types.

SQL NamestorageDescription
inet8 bytesIPv4 addresses with subnet mask support
inet44 bytesIPv4 addresses without CIDR network mask information
inet616 bytesIPv6 addresses without CIDR network mask information

Info: The inet4 and inet6 types are available since Dec2025 (11.55) release only.

Note: The 0 address (0.0.0.0 and ::) are used as NULL value and can therefore not be used as address value.

Usage example:

CREATE TABLE inet_example (a inet, b inet4, c inet6);

INSERT INTO inet_example (a, b, c)
VALUES ('192.168.1.5/24', '192.168.1.5', '2001:DB8:85A3::8A2E:370:7334');

SELECT * FROM inet_example;

+-----------------------------+-----------------+------------------------------+
| a                           | b               | c                            |
+=============================+=================+==============================+
| 192.168.1.5/24              | 192.168.1.5     | 2001:db8:85a3::8a2e:370:7334 |
+-----------------------------+-----------------+------------------------------+

Conversion

A valid IPv4 or IPv6 Address string has a specific syntax, see IPv4 address, IPv6 address.

You can use the standard cast() or convert() functions to convert a valid IP adress string into an inet or inet4 or inet6 type value. You can also use the inet or inet4 or inet6 casting prefix. See examples:

select cast('192.168.1.5/24' as inet);
select convert('192.168.1.5/24', inet);
select inet '192.168.1.5/24';

select cast('192.168.1.5' as inet4);
select convert('192.168.1.5', inet4);
select inet4 '192.168.1.5';

select cast('2001:0db8:85a3:0000:0000:8a2e:0370:7334' as inet6);
select convert('2001:0db8:85a3:0000:0000:8a2e:0370:7334', inet6);
select inet6 '2001:0db8:85a3:0000:0000:8a2e:0370:7334';

Functions

The inet module contains a collection of inet functions and inet operators that operate on inet type (IPv4 addresses with optional subnet mask). 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.

The inet46 module contains various functions to check whether an inet4 or inet6 address is contained in a (sub)net (where an extra CIDR netmask column is also needed). See inet4 functions that operate on inet4 type and inet6 functions that operate on inet6 type.