The cidr type stores networks specified in CIDR (Classless Inter-Domain Routing) notation. The inet type stores hosts and networks in CIDR notation using a simple variation in representation to represent simple host TCP/IP addresses.
Table 3-19. PostgresIP Version 4 Types
|cidr||variable||CIDR networks||Valid IPV4 CIDR blocks|
|inet||variable||nets and hosts||Valid IPV4 CIDR blocks|
The cidr type holds a CIDR network. The format for specifying classless networks is x.x.x.x/y where x.x.x.x is the network and /y is the number of bits in the netmask. If /y omitted, it is calculated using assumptions from the older classfull naming system except that it is extended to include at least all of the octets in the input.
Here are some examples:
Table 3-20. PostgresIP Types Examples
|CIDR Input||CIDR Displayed|
The inet type is designed to hold, in one field, all of the information about a host including the CIDR-style subnet that it is in. Note that if you want to store proper CIDR networks, you should use the cidr type. The inet type is similar to the cidr type except that the bits in the host part can be non-zero. Functions exist to extract the various elements of the field.
The input format for this function is x.x.x.x/y where x.x.x.x is an internet host and y is the number of bits in the netmask. If the /y part is left off, it is treated as /32. On output, the /y part is not printed if it is /32. This allows the type to be used as a straight host type by just leaving off the bits part.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.