The cidr type stores networks specified in CIDR notation. The inet type stores hosts and networks in CIDR notation.
Table 8-14. 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 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 the "/y" part is left off, it is calculated using assumptions from the old class system except that it is extended to include at least all of the octets in the input. Here are some examples:
Table 8-15. 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, see 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 of the bits part.