1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>Network Address Types</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
16
HREF="datatype.html"><LINK
18
TITLE="Geometric Types"
19
HREF="datatype-geometric.html"><LINK
21
TITLE="Bit String Types"
22
HREF="datatype-bit.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="Geometric Types"
57
HREF="datatype-geometric.html"
74
>Chapter 8. Data Types</TD
89
TITLE="Bit String Types"
90
HREF="datatype-bit.html"
104
NAME="DATATYPE-NET-TYPES"
105
>8.9. Network Address Types</A
111
> offers data types to store IPv4, IPv6, and MAC
112
addresses, as shown in <A
113
HREF="datatype-net-types.html#DATATYPE-NET-TYPES-TABLE"
116
is better to use these types instead of plain text types to store
117
network addresses, because
118
these types offer input error checking and specialized
119
operators and functions (see <A
120
HREF="functions-net.html"
127
NAME="DATATYPE-NET-TYPES-TABLE"
131
>Table 8-21. Network Address Types</B
136
><COL><COL><COL><THEAD
156
>IPv4 and IPv6 networks</TD
167
>IPv4 and IPv6 hosts and networks</TD
191
IPv4 addresses will always sort before IPv6 addresses, including
192
IPv4 addresses encapsulated or mapped to IPv6 addresses, such as
193
::10.2.3.4 or ::ffff:10.4.3.2.
210
> type holds an IPv4 or IPv6 host address, and
211
optionally its subnet, all in one field.
212
The subnet is represented by the number of network address bits
213
present in the host address (the
217
>). If the netmask is 32 and the address is IPv4,
218
then the value does not indicate a subnet, only a single host.
219
In IPv6, the address length is 128 bits, so 128 bits specify a
220
unique host address. Note that if you
221
want to accept only networks, you should use the
225
> type rather than <TT
231
> The input format for this type is
245
is an IPv4 or IPv6 address and
252
is the number of bits in the netmask. If the
259
portion is missing, the
260
netmask is 32 for IPv4 and 128 for IPv6, so the value represents
261
just a single host. On display, the
268
portion is suppressed if the netmask specifies a single host.
286
> type holds an IPv4 or IPv6 network specification.
287
Input and output formats follow Classless Internet Domain Routing
289
The format for specifying networks is <TT
299
> is the network represented as an
300
IPv4 or IPv6 address, and <TT
305
> is the number of bits in the netmask. If
311
> is omitted, it is calculated
312
using assumptions from the older classful network numbering system, except
313
it will be at least large enough to include all of the octets
314
written in the input. It is an error to specify a network address
315
that has bits set to the right of the specified netmask.
319
HREF="datatype-net-types.html#DATATYPE-NET-CIDR-TABLE"
321
> shows some examples.
326
NAME="DATATYPE-NET-CIDR-TABLE"
333
> Type Input Examples</B
338
><COL><COL><COL><THEAD
366
>192.168.100.128/25</TD
368
>192.168.100.128/25</TD
370
>192.168.100.128/25</TD
462
>2001:4f8:3:ba::/64</TD
464
>2001:4f8:3:ba::/64</TD
466
>2001:4f8:3:ba::/64</TD
470
>2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128</TD
472
>2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128</TD
474
>2001:4f8:3:ba:2e0:81ff:fe22:d1f1</TD
478
>::ffff:1.2.3.0/120</TD
480
>::ffff:1.2.3.0/120</TD
482
>::ffff:1.2.3/120</TD
486
>::ffff:1.2.3.0/128</TD
488
>::ffff:1.2.3.0/128</TD
490
>::ffff:1.2.3.0/128</TD
501
NAME="DATATYPE-INET-VS-CIDR"
511
> The essential difference between <TT
518
data types is that <TT
521
> accepts values with nonzero bits to
522
the right of the netmask, whereas <TT
534
> If you do not like the output format for <TT
541
> values, try the functions <CODE
561
NAME="DATATYPE-MACADDR"
571
> type stores MAC addresses, known for example
572
from Ethernet card hardware addresses (although MAC addresses are
573
used for other purposes as well). Input is accepted in the
585
>'08:00:2b:01:02:03'</TT
592
>'08-00-2b-01-02-03'</TT
613
>'0800.2b01.0203'</TT
629
These examples would all specify the same address. Upper and
630
lower case is accepted for the digits
637
>. Output is always in the
638
first of the forms shown.
641
> IEEE Std 802-2001 specifies the second shown form (with hyphens)
642
as the canonical form for MAC addresses, and specifies the first
643
form (with colons) as the bit-reversed notation, so that
644
08-00-2b-01-02-03 = 01:00:4D:08:04:0C. This convention is widely
645
ignored nowadays, and it is only relevant for obsolete network
646
protocols (such as Token Ring). PostgreSQL makes no provisions
647
for bit reversal, and all accepted formats use the canonical LSB
651
> The remaining four input formats are not part of any standard.
660
SUMMARY="Footer navigation table"
671
HREF="datatype-geometric.html"
689
HREF="datatype-bit.html"
713
>Bit String Types</TD
b'\\ No newline at end of file'