postgresql_16:3.5.9 Network Address Types
PostgreSQL 16 > The SQL Language > Data Types > Network Address Types
PostgreSQL offers data types to store IPv4, IPv6, and MAC addresses, as shown in (see datatype-net-types-table). It is better to use these types instead of plain text types to store network addresses, because these types offer input error checking and specialized operators and functions (see (see postgresql_16:3.6.12)).
| Name | Storage Size | Description | | --- | --- | --- | | cidr | 7 or 19 bytes | IPv4 and IPv6 networks | | inet | 7 or 19 bytes | IPv4 and IPv6 hosts and networks | | macaddr | 6 bytes | MAC addresses | | macaddr8 | 8 bytes | MAC addresses (EUI-64 format) |
When sorting inet or cidr data types, IPv4 addresses will always sort before IPv6 addresses, including IPv4 addresses encapsulated or mapped to IPv6 addresses, such as ::10.2.3.4 or ::ffff:10.4.3.2.
Subsections
- postgresql_16:3.5.9.1
inet - postgresql_16:3.5.9.2
cidr - postgresql_16:3.5.9.3
inetvs.cidr - postgresql_16:3.5.9.4
macaddr - postgresql_16:3.5.9.5
macaddr8