{"Entry":{"collection":"type","key":"macaddr","name":"macaddr","aliases":[],"metadata":{"aliases":[],"category":"Other built-in types","content_hash":"572dafcffa21fdb13d22491dac97442487d7ba2c32063c86b0806d98928b035f","imported_at":"2026-09-30T00:40:36.176734+08:00","name":"macaddr","name_zh":"","slug":"macaddr","summary":"MAC (Media Access Control) address"}},"Definition":{"Collection":"type","Key":"macaddr","SourceDatabase":"center","Version":"18","SourceTable":"data_type","SourceKey":"macaddr","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"aliases":[],"casts":[{"castcontext":"i","castfunc":"macaddr8","castmethod":"f","castsource":"macaddr","casttarget":"macaddr8"},{"castcontext":"i","castfunc":"macaddr","castmethod":"f","castsource":"macaddr8","casttarget":"macaddr"}],"catalog":{"array_type_name":"_macaddr","array_type_oid":"1040","descr":"XX:XX:XX:XX:XX:XX, MAC address","oid":"829","typacl":"_null_","typalign":"i","typanalyze":"-","typarray":"0","typbasetype":"0","typbyval":"f","typcategory":"U","typcollation":"0","typdefault":"_null_","typdefaultbin":"_null_","typdelim":"','","typelem":"0","typinput":"macaddr_in","typisdefined":"t","typispreferred":"f","typlen":"6","typmodin":"-","typmodout":"-","typname":"macaddr","typnamespace":"pg_catalog","typndims":"0","typnotnull":"f","typoutput":"macaddr_out","typowner":"POSTGRES","typreceive":"macaddr_recv","typrelid":"0","typsend":"macaddr_send","typstorage":"p","typsubscript":"-","typtype":"b","typtypmod":"-1"},"comparison_data":{"aliases":[],"casts":[{"castcontext":"i","castfunc":"macaddr","castmethod":"f","castsource":"macaddr8","casttarget":"macaddr"},{"castcontext":"i","castfunc":"macaddr8","castmethod":"f","castsource":"macaddr","casttarget":"macaddr8"}],"catalog":{"array_type_name":"_macaddr","typacl":"_null_","typalign":"i","typanalyze":"-","typarray":"_macaddr","typbasetype":"0","typbyval":"f","typcategory":"U","typcollation":"0","typdefault":"_null_","typdefaultbin":"_null_","typdelim":",","typelem":"0","typinput":"macaddr_in","typisdefined":"t","typispreferred":"f","typlen":"6","typmodin":"-","typmodout":"-","typname":"macaddr","typndims":"0","typnotnull":"f","typoutput":"macaddr_out","typreceive":"macaddr_recv","typrelid":"0","typsend":"macaddr_send","typstorage":"p","typsubscript":"-","typtype":"b","typtypmod":"-1"},"facts":[{"label":"Catalog name","value":"pg_catalog.macaddr"},{"label":"Declared length","value":"6 bytes"},{"label":"Documented declaration","value":"macaddr"},{"label":"Input function","value":"macaddr_in"},{"label":"Output function","value":"macaddr_out"},{"label":"Storage Size","value":"6 bytes"},{"label":"Storage strategy","value":"plain"},{"label":"Type OID","value":"829"},{"label":"Type kind","value":"Base type"}],"operator_classes":[{"opcdefault":"f","opcfamily":"brin/macaddr_bloom_ops","opcintype":"macaddr","opckeytype":"macaddr","opcmethod":"brin","opcname":"macaddr_bloom_ops"},{"opcdefault":"f","opcfamily":"brin/macaddr_minmax_multi_ops","opcintype":"macaddr","opckeytype":"macaddr","opcmethod":"brin","opcname":"macaddr_minmax_multi_ops"},{"opcdefault":"t","opcfamily":"brin/macaddr_minmax_ops","opcintype":"macaddr","opckeytype":"macaddr","opcmethod":"brin","opcname":"macaddr_minmax_ops"},{"opcdefault":"t","opcfamily":"btree/macaddr_ops","opcintype":"macaddr","opckeytype":"0","opcmethod":"btree","opcname":"macaddr_ops"},{"opcdefault":"t","opcfamily":"hash/macaddr_ops","opcintype":"macaddr","opckeytype":"0","opcmethod":"hash","opcname":"macaddr_ops"}],"operators":[{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_and","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"macaddr","oprname":"\u0026","oprnegate":"0","oprrest":"-","oprresult":"macaddr","oprright":"macaddr"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_ge","oprcom":"\u003c=(macaddr,macaddr)","oprjoin":"scalargejoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003e=","oprnegate":"\u003c(macaddr,macaddr)","oprrest":"scalargesel","oprresult":"bool","oprright":"macaddr"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_gt","oprcom":"\u003c(macaddr,macaddr)","oprjoin":"scalargtjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003e","oprnegate":"\u003c=(macaddr,macaddr)","oprrest":"scalargtsel","oprresult":"bool","oprright":"macaddr"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_le","oprcom":"\u003e=(macaddr,macaddr)","oprjoin":"scalarlejoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003c=","oprnegate":"\u003e(macaddr,macaddr)","oprrest":"scalarlesel","oprresult":"bool","oprright":"macaddr"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_lt","oprcom":"\u003e(macaddr,macaddr)","oprjoin":"scalarltjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003c","oprnegate":"\u003e=(macaddr,macaddr)","oprrest":"scalarltsel","oprresult":"bool","oprright":"macaddr"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_ne","oprcom":"\u003c\u003e(macaddr,macaddr)","oprjoin":"neqjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003c\u003e","oprnegate":"=(macaddr,macaddr)","oprrest":"neqsel","oprresult":"bool","oprright":"macaddr"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_not","oprcom":"0","oprjoin":"-","oprkind":"l","oprleft":"0","oprname":"~","oprnegate":"0","oprrest":"-","oprresult":"macaddr","oprright":"macaddr"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_or","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"macaddr","oprname":"|","oprnegate":"0","oprrest":"-","oprresult":"macaddr","oprright":"macaddr"},{"oprcanhash":"t","oprcanmerge":"t","oprcode":"macaddr_eq","oprcom":"=(macaddr,macaddr)","oprjoin":"eqjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"=","oprnegate":"\u003c\u003e(macaddr,macaddr)","oprrest":"eqsel","oprresult":"bool","oprright":"macaddr"}],"ranges":[]},"comparison_hash":"3283673affdd8120b8146304a37bcef1ed9fb61f699462b51875c1ecfbae6573","coverage":"source inventory; exact declared input types for operator classes","description":["MAC (Media Access Control) address"],"facts":[{"label":"Catalog name","value":"pg_catalog.macaddr"},{"label":"Type OID","value":"829"},{"label":"Type kind","value":"Base type"},{"label":"Declared length","value":"6 bytes"},{"label":"Storage strategy","value":"plain"},{"label":"Input function","value":"macaddr_in"},{"label":"Output function","value":"macaddr_out"},{"label":"Documented declaration","value":"macaddr"},{"label":"Storage Size","value":"6 bytes"},{"label":"Manual description","value":"MAC addresses"}],"manual_documentation":"dedicated family chapter","manual_html":"\u003cdiv class=\"sect1\" id=\"DATATYPE-NET-TYPES\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e8.9. Network Address Types \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e offers data types to store IPv4, IPv6, and MAC addresses, as shown in \u003ca class=\"xref\" href=\"/docs/18/datatype-net-types.html#DATATYPE-NET-TYPES-TABLE\" title=\"Table 8.21. Network Address Types\"\u003eTable 8.21\u003c/a\u003e. 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 \u003ca class=\"xref\" href=\"/docs/18/functions-net.html\" title=\"9.12. Network Address Functions and Operators\"\u003eSection 9.12\u003c/a\u003e).\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"DATATYPE-NET-TYPES-TABLE\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 8.21. Network Address Types\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eName\u003c/th\u003e\n\u003cth\u003eStorage Size\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7 or 19 bytes\u003c/td\u003e\n\u003ctd\u003eIPv4 and IPv6 networks\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003einet\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7 or 19 bytes\u003c/td\u003e\n\u003ctd\u003eIPv4 and IPv6 hosts and networks\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003emacaddr\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e6 bytes\u003c/td\u003e\n\u003ctd\u003eMAC addresses\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003emacaddr8\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e8 bytes\u003c/td\u003e\n\u003ctd\u003eMAC addresses (EUI-64 format)\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eWhen sorting \u003ccode class=\"type\"\u003einet\u003c/code\u003e or \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e 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.\u003c/p\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-INET\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.1. \u003ccode class=\"type\"\u003einet\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003einet\u003c/code\u003e type holds an IPv4 or IPv6 host address, and optionally its subnet, all in one field. The subnet is represented by the number of network address bits present in the host address (the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003enetmask\u003c/span\u003e”\u003c/span\u003e). If the netmask is 32 and the address is IPv4, then the value does not indicate a subnet, only a single host. In IPv6, the address length is 128 bits, so 128 bits specify a unique host address. Note that if you want to accept only networks, you should use the \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e type rather than \u003ccode class=\"type\"\u003einet\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe input format for this type is \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress/y\u003c/code\u003e\u003c/em\u003e where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress\u003c/code\u003e\u003c/em\u003e is an IPv4 or IPv6 address and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is the number of bits in the netmask. If the \u003cem class=\"replaceable\"\u003e\u003ccode\u003e/y\u003c/code\u003e\u003c/em\u003e portion is omitted, the netmask is taken to be 32 for IPv4 or 128 for IPv6, so the value represents just a single host. On display, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003e/y\u003c/code\u003e\u003c/em\u003e portion is suppressed if the netmask specifies a single host.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-CIDR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.2. \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e type holds an IPv4 or IPv6 network specification. Input and output formats follow Classless Internet Domain Routing conventions. The format for specifying networks is \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress/y\u003c/code\u003e\u003c/em\u003e where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress\u003c/code\u003e\u003c/em\u003e is the network's lowest address represented as an IPv4 or IPv6 address, and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is the number of bits in the netmask. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is omitted, it is calculated using assumptions from the older classful network numbering system, except it will be at least large enough to include all of the octets written in the input. It is an error to specify a network address that has bits set to the right of the specified netmask.\u003c/p\u003e\n\u003cp\u003e\u003ca class=\"xref\" href=\"/docs/18/datatype-net-types.html#DATATYPE-NET-CIDR-TABLE\" title=\"Table 8.22. cidr Type Input Examples\"\u003eTable 8.22\u003c/a\u003e shows some examples.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"DATATYPE-NET-CIDR-TABLE\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 8.22. \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e Type Input Examples\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003e\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e Input\u003c/th\u003e\n\u003cth\u003e\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e Output\u003c/th\u003e\n\u003cth\u003e\u003ccode class=\"literal\"\u003e\u003ccode class=\"function\"\u003eabbrev(\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e)\u003c/code\u003e\u003c/code\u003e\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168/24\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.0/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168/25\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/25\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/25\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168.1\u003c/td\u003e\n\u003ctd\u003e192.168.1.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.1/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.0/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128.1\u003c/td\u003e\n\u003ctd\u003e128.1.0.0/16\u003c/td\u003e\n\u003ctd\u003e128.1/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128\u003c/td\u003e\n\u003ctd\u003e128.0.0.0/16\u003c/td\u003e\n\u003ctd\u003e128.0/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128.1.2\u003c/td\u003e\n\u003ctd\u003e128.1.2.0/24\u003c/td\u003e\n\u003ctd\u003e128.1.2/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1.2\u003c/td\u003e\n\u003ctd\u003e10.1.2.0/24\u003c/td\u003e\n\u003ctd\u003e10.1.2/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1\u003c/td\u003e\n\u003ctd\u003e10.1.0.0/16\u003c/td\u003e\n\u003ctd\u003e10.1/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10\u003c/td\u003e\n\u003ctd\u003e10.0.0.0/8\u003c/td\u003e\n\u003ctd\u003e10/8\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e2001:4f8:3:ba::/64\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba::/64\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba/64\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e::ffff:1.2.3.0/120\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/120\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3/120\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-INET-VS-CIDR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.3. \u003ccode class=\"type\"\u003einet\u003c/code\u003e vs. \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe essential difference between \u003ccode class=\"type\"\u003einet\u003c/code\u003e and \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e data types is that \u003ccode class=\"type\"\u003einet\u003c/code\u003e accepts values with nonzero bits to the right of the netmask, whereas \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e does not. For example, \u003ccode class=\"literal\"\u003e192.168.0.1/24\u003c/code\u003e is valid for \u003ccode class=\"type\"\u003einet\u003c/code\u003e but not for \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eIf you do not like the output format for \u003ccode class=\"type\"\u003einet\u003c/code\u003e or \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e values, try the functions \u003ccode class=\"function\"\u003ehost\u003c/code\u003e, \u003ccode class=\"function\"\u003etext\u003c/code\u003e, and \u003ccode class=\"function\"\u003eabbrev\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-MACADDR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.4. \u003ccode class=\"type\"\u003emacaddr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003emacaddr\u003c/code\u003e type stores MAC addresses, known for example from Ethernet card hardware addresses (although MAC addresses are used for other purposes as well). Input is accepted in the following formats:\u003c/p\u003e\n\u003ctable class=\"simplelist\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08:00:2b:01:02:03'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08-00-2b-01-02-03'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b:010203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b-010203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800.2b01.0203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800-2b01-0203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b010203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cp\u003eThese examples all specify the same address. Upper and lower case is accepted for the digits \u003ccode class=\"literal\"\u003ea\u003c/code\u003e through \u003ccode class=\"literal\"\u003ef\u003c/code\u003e. Output is always in the first of the forms shown.\u003c/p\u003e\n\u003cp\u003eIEEE Standard 802-2001 specifies the second form shown (with hyphens) as the canonical form for MAC addresses, and specifies the first form (with colons) as used with bit-reversed, MSB-first notation, so that 08-00-2b-01-02-03 = 10:00:D4:80:40:C0. This convention is widely ignored nowadays, and it is relevant only for obsolete network protocols (such as Token Ring). PostgreSQL makes no provisions for bit reversal; all accepted formats use the canonical LSB order.\u003c/p\u003e\n\u003cp\u003eThe remaining five input formats are not part of any standard.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-MACADDR8\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.5. \u003ccode class=\"type\"\u003emacaddr8\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003emacaddr8\u003c/code\u003e type stores MAC addresses in EUI-64 format, known for example from Ethernet card hardware addresses (although MAC addresses are used for other purposes as well). This type can accept both 6 and 8 byte length MAC addresses and stores them in 8 byte length format. MAC addresses given in 6 byte format will be stored in 8 byte length format with the 4th and 5th bytes set to FF and FE, respectively. Note that IPv6 uses a modified EUI-64 format where the 7th bit should be set to one after the conversion from EUI-48. The function \u003ccode class=\"function\"\u003emacaddr8_set7bit\u003c/code\u003e is provided to make this change. Generally speaking, any input which is comprised of pairs of hex digits (on byte boundaries), optionally separated consistently by one of \u003ccode class=\"literal\"\u003e':'\u003c/code\u003e, \u003ccode class=\"literal\"\u003e'-'\u003c/code\u003e or \u003ccode class=\"literal\"\u003e'.'\u003c/code\u003e, is accepted. The number of hex digits must be either 16 (8 bytes) or 12 (6 bytes). Leading and trailing whitespace is ignored. The following are examples of input formats that are accepted:\u003c/p\u003e\n\u003ctable class=\"simplelist\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08:00:2b:01:02:03:04:05'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08-00-2b-01-02-03-04-05'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b:0102030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b-0102030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800.2b01.0203.0405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800-2b01-0203-0405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b01:02030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b0102030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cp\u003eThese examples all specify the same address. Upper and lower case is accepted for the digits \u003ccode class=\"literal\"\u003ea\u003c/code\u003e through \u003ccode class=\"literal\"\u003ef\u003c/code\u003e. Output is always in the first of the forms shown.\u003c/p\u003e\n\u003cp\u003eThe last six input formats shown above are not part of any standard.\u003c/p\u003e\n\u003cp\u003eTo convert a traditional 48 bit MAC address in EUI-48 format to modified EUI-64 format to be included as the host portion of an IPv6 address, use \u003ccode class=\"function\"\u003emacaddr8_set7bit\u003c/code\u003e as shown:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT macaddr8_set7bit('08:00:2b:01:02:03');\n\u003ccode class=\"computeroutput\"\u003e\n    macaddr8_set7bit\n-------------------------\n 0a:00:2b:ff:fe:01:02:03\n(1 row)\n\u003c/code\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e","manual_path":"datatype-net-types.html","operator_classes":[{"opcdefault":"t","opcfamily":"btree/macaddr_ops","opcintype":"macaddr","opckeytype":"0","opcmethod":"btree","opcname":"macaddr_ops","opcnamespace":"pg_catalog","opcowner":"POSTGRES"},{"opcdefault":"t","opcfamily":"hash/macaddr_ops","opcintype":"macaddr","opckeytype":"0","opcmethod":"hash","opcname":"macaddr_ops","opcnamespace":"pg_catalog","opcowner":"POSTGRES"},{"opcdefault":"t","opcfamily":"brin/macaddr_minmax_ops","opcintype":"macaddr","opckeytype":"macaddr","opcmethod":"brin","opcname":"macaddr_minmax_ops","opcnamespace":"pg_catalog","opcowner":"POSTGRES"},{"opcdefault":"f","opcfamily":"brin/macaddr_minmax_multi_ops","opcintype":"macaddr","opckeytype":"macaddr","opcmethod":"brin","opcname":"macaddr_minmax_multi_ops","opcnamespace":"pg_catalog","opcowner":"POSTGRES"},{"opcdefault":"f","opcfamily":"brin/macaddr_bloom_ops","opcintype":"macaddr","opckeytype":"macaddr","opcmethod":"brin","opcname":"macaddr_bloom_ops","opcnamespace":"pg_catalog","opcowner":"POSTGRES"}],"operators":[{"descr":"equal","oid":"1220","oprcanhash":"t","oprcanmerge":"t","oprcode":"macaddr_eq","oprcom":"=(macaddr,macaddr)","oprjoin":"eqjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"=","oprnamespace":"pg_catalog","oprnegate":"\u003c\u003e(macaddr,macaddr)","oprowner":"POSTGRES","oprrest":"eqsel","oprresult":"bool","oprright":"macaddr"},{"descr":"not equal","oid":"1221","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_ne","oprcom":"\u003c\u003e(macaddr,macaddr)","oprjoin":"neqjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003c\u003e","oprnamespace":"pg_catalog","oprnegate":"=(macaddr,macaddr)","oprowner":"POSTGRES","oprrest":"neqsel","oprresult":"bool","oprright":"macaddr"},{"descr":"less than","oid":"1222","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_lt","oprcom":"\u003e(macaddr,macaddr)","oprjoin":"scalarltjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003c","oprnamespace":"pg_catalog","oprnegate":"\u003e=(macaddr,macaddr)","oprowner":"POSTGRES","oprrest":"scalarltsel","oprresult":"bool","oprright":"macaddr"},{"descr":"less than or equal","oid":"1223","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_le","oprcom":"\u003e=(macaddr,macaddr)","oprjoin":"scalarlejoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003c=","oprnamespace":"pg_catalog","oprnegate":"\u003e(macaddr,macaddr)","oprowner":"POSTGRES","oprrest":"scalarlesel","oprresult":"bool","oprright":"macaddr"},{"descr":"greater than","oid":"1224","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_gt","oprcom":"\u003c(macaddr,macaddr)","oprjoin":"scalargtjoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003e","oprnamespace":"pg_catalog","oprnegate":"\u003c=(macaddr,macaddr)","oprowner":"POSTGRES","oprrest":"scalargtsel","oprresult":"bool","oprright":"macaddr"},{"descr":"greater than or equal","oid":"1225","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_ge","oprcom":"\u003c=(macaddr,macaddr)","oprjoin":"scalargejoinsel","oprkind":"b","oprleft":"macaddr","oprname":"\u003e=","oprnamespace":"pg_catalog","oprnegate":"\u003c(macaddr,macaddr)","oprowner":"POSTGRES","oprrest":"scalargesel","oprresult":"bool","oprright":"macaddr"},{"descr":"bitwise not","oid":"3147","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_not","oprcom":"0","oprjoin":"-","oprkind":"l","oprleft":"0","oprname":"~","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"-","oprresult":"macaddr","oprright":"macaddr"},{"descr":"bitwise and","oid":"3148","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_and","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"macaddr","oprname":"\u0026","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"-","oprresult":"macaddr","oprright":"macaddr"},{"descr":"bitwise or","oid":"3149","oprcanhash":"f","oprcanmerge":"f","oprcode":"macaddr_or","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"macaddr","oprname":"|","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"-","oprresult":"macaddr","oprright":"macaddr"}],"ranges":[],"related":[{"label":"pg_type catalog","url":"/wiki/catalog/pg_type/?v=18"},{"label":"pg_cast catalog","url":"/wiki/catalog/pg_cast/?v=18"},{"label":"pg_operator catalog","url":"/wiki/catalog/pg_operator/?v=18"},{"label":"pg_opclass catalog","url":"/wiki/catalog/pg_opclass/?v=18"},{"label":"Arrays","url":"/wiki/type/arrays/?v=18"},{"label":"brin index access method","url":"/wiki/indexam/brin/?v=18"},{"label":"btree index access method","url":"/wiki/indexam/btree/?v=18"},{"label":"hash index access method","url":"/wiki/indexam/hash/?v=18"}],"release":{"channel":"stable","label":"18.6","major":"18","manual_sha256":{"arrays.html":"0e1d5c5a7b4a949d4439995f44f74ad4264e050d16eb9ad2a850fbaee04032df","catalog-pg-type.html":"ea9c9313bab8e92a7da18ebc50c7ff1f908dd80999a7e0ca3bbc82ba626c58d4","datatype-binary.html":"0c03ec47b76e37888a3da7f5dcfd340128a5d356642a85185cc9ebe17856a904","datatype-bit.html":"c49124aad561636c18080b9e09572fde7785a6b9eae86f5a33283f0fd6774c37","datatype-boolean.html":"b633f663e6c8276e7056287640c413aa79dbc15d5353cee0d41653d58d376956","datatype-character.html":"c73eebe413ea709a7792e4cfc3cfe9fb68cb496ebe83c3ebaa9d09f8c40d0f73","datatype-datetime.html":"e366275d8b13845bfa4ef0d68faa093e5f3ecb708a1ec870cbcbf7e425b85699","datatype-enum.html":"cab38e53222e30cc94b24de4b33634fd22d7c93f58ebcf35f646c9b8da78fae8","datatype-geometric.html":"0eb3053cfe7d6b0a4b5592c5d7af8d97cae527e87f063c5793413bcba5c14cd9","datatype-json.html":"650162a05b660146b500a205d523374d00aee117a6a6240d30262be51b6e33e5","datatype-money.html":"8b29c14b90679683ac5c472b59a0a7e2853f32cc7db43fab417b2697a6879964","datatype-net-types.html":"96846e641cc37727ddcd8b8a1aa0dbe33cd9787760a2b4efb0dcb9403d5be63f","datatype-numeric.html":"b74619f7ac2f1ca9f85c48073df78c33dd30e464e61baba6008634534edcb500","datatype-oid.html":"8b3360302225f08ae72716ce1804596de95b568e5d31f788cb4597427b28cc38","datatype-pg-lsn.html":"339172f5107cc7eb7139bec911277647219e92a532cebd0f3da0a5dacf8195af","datatype-pseudo.html":"c7cf0b8214304bd8702c95f2142671ae5f0d631f83717f9c07d9e1f2579961b4","datatype-textsearch.html":"4b15e05be8b49a71b28aea22f2c46d0dbf639a91e7b4fe129a4c737c6daad47c","datatype-uuid.html":"292b307b3223c6182bdba687e7f69e6dca9038430143ad79d56327f6ed4c3246","datatype-xml.html":"061fc2295b7b69be704f0a741b8decd10ad721059f871fb0243c669bb54d7822","datatype.html":"e581f67c74e42006289638c8659e9b338adbfd7f068bd8bf2b3be3880fcd2254","domains.html":"82d486973ccc35d14276627a67ac76b434452f23f9ed4d8aa3fbb01fdf285fc2","functions-info.html":"78ac80bf81da2e4f4a33f3b850faa86f0f58ec54a083d6c31da557907de0df87","rangetypes.html":"e4960abc7ce8e51d794f94f1e57b099d30b7f75dd7f2b23a960eef91f6291c33","rowtypes.html":"74f99e029c3a9edfd3e18810ba3c8cb66d3aada91eb67b86476560871e6617e9","sql-createdomain.html":"e94f927196de1b0ea1ce35cd4603c1f6f544439adcc0edf1c4222358e832245b"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_files":{"doc/src/sgml/datatype.sgml":"86328daa77e20d81d222376ec0306d9841a17104e436c08d138eb763aefb3700","src/include/catalog/pg_am.dat":"b3cb86b102a42fb0024cbd99779c9897afb40d12a71f5cc5a0e5aee7ff2f9969","src/include/catalog/pg_am.h":"3426799df799f32163fcc0765f43dbdb5e88e626acf31284fef9fc6014b69d8e","src/include/catalog/pg_cast.dat":"97911281ca2c81917394ccb2ec13367e37c6801fd461d5e1a3d2f28b911b46b2","src/include/catalog/pg_cast.h":"de585c7df687d698e7d1d100dce8a794ac9da52414ea48169191019178c8f053","src/include/catalog/pg_opclass.dat":"4ee7d3619a6aa106e1c0db55de903931c7d11b1c60ba053a022519c55f8ee668","src/include/catalog/pg_opclass.h":"9c218537806c8ef0398302faaca7f91315dfc1198c48706cebffb479b68defaf","src/include/catalog/pg_operator.dat":"5d35b9b2ef5f9797cc815263927ef8a12367fedace53e828b4e8b320e2a7f703","src/include/catalog/pg_operator.h":"621b18cfffe102413d79b746ce7a10f77fc60fdd097bac34c22b31070d3ee3c4","src/include/catalog/pg_opfamily.dat":"3b694879027b858f2ecf1fa1152b7e30c6e15a216ba99c2384291c30e9d52311","src/include/catalog/pg_opfamily.h":"e1f5fc8aebd3042df847455bf66bf755f768c2aa8a9b03d22f7ec8563eba59c0","src/include/catalog/pg_proc.dat":"1f934ce80d460159dda137714374a35f9896315ea2476709cbb4da13b38ef95a","src/include/catalog/pg_proc.h":"f7d59f07c5b95e2f3c7141762a0f576e8a3af7581ba54c27537f4d500472bea5","src/include/catalog/pg_range.dat":"5c2271f8e89e9378d1887204e5785060b77405b5f0ff3e6c719250c9c1dcfcc4","src/include/catalog/pg_range.h":"45546d952b5181f989bd9234721897fc2b37005c8e49ce2ddc156f26974c3ca4","src/include/catalog/pg_type.dat":"5f5887b75677cba2d4a1a0cfeb355df5ed91f85d385fac88bd8d7c605b3578f9","src/include/catalog/pg_type.h":"8fb198749fd82b6c1818a3c18455f226f66116fcfeb3d4959c65ce3fda22802e"},"source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"macaddr","sources":[{"label":"PostgreSQL 18 English manual","path":"datatype-net-types.html","sha256":"96846e641cc37727ddcd8b8a1aa0dbe33cd9787760a2b4efb0dcb9403d5be63f","url":"/docs/18/datatype-net-types.html"},{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"}]},"ManualEvidence":{"manual_path":"datatype-net-types.html","release":{"channel":"stable","label":"18.6","major":"18","manual_sha256":{"arrays.html":"0e1d5c5a7b4a949d4439995f44f74ad4264e050d16eb9ad2a850fbaee04032df","catalog-pg-type.html":"ea9c9313bab8e92a7da18ebc50c7ff1f908dd80999a7e0ca3bbc82ba626c58d4","datatype-binary.html":"0c03ec47b76e37888a3da7f5dcfd340128a5d356642a85185cc9ebe17856a904","datatype-bit.html":"c49124aad561636c18080b9e09572fde7785a6b9eae86f5a33283f0fd6774c37","datatype-boolean.html":"b633f663e6c8276e7056287640c413aa79dbc15d5353cee0d41653d58d376956","datatype-character.html":"c73eebe413ea709a7792e4cfc3cfe9fb68cb496ebe83c3ebaa9d09f8c40d0f73","datatype-datetime.html":"e366275d8b13845bfa4ef0d68faa093e5f3ecb708a1ec870cbcbf7e425b85699","datatype-enum.html":"cab38e53222e30cc94b24de4b33634fd22d7c93f58ebcf35f646c9b8da78fae8","datatype-geometric.html":"0eb3053cfe7d6b0a4b5592c5d7af8d97cae527e87f063c5793413bcba5c14cd9","datatype-json.html":"650162a05b660146b500a205d523374d00aee117a6a6240d30262be51b6e33e5","datatype-money.html":"8b29c14b90679683ac5c472b59a0a7e2853f32cc7db43fab417b2697a6879964","datatype-net-types.html":"96846e641cc37727ddcd8b8a1aa0dbe33cd9787760a2b4efb0dcb9403d5be63f","datatype-numeric.html":"b74619f7ac2f1ca9f85c48073df78c33dd30e464e61baba6008634534edcb500","datatype-oid.html":"8b3360302225f08ae72716ce1804596de95b568e5d31f788cb4597427b28cc38","datatype-pg-lsn.html":"339172f5107cc7eb7139bec911277647219e92a532cebd0f3da0a5dacf8195af","datatype-pseudo.html":"c7cf0b8214304bd8702c95f2142671ae5f0d631f83717f9c07d9e1f2579961b4","datatype-textsearch.html":"4b15e05be8b49a71b28aea22f2c46d0dbf639a91e7b4fe129a4c737c6daad47c","datatype-uuid.html":"292b307b3223c6182bdba687e7f69e6dca9038430143ad79d56327f6ed4c3246","datatype-xml.html":"061fc2295b7b69be704f0a741b8decd10ad721059f871fb0243c669bb54d7822","datatype.html":"e581f67c74e42006289638c8659e9b338adbfd7f068bd8bf2b3be3880fcd2254","domains.html":"82d486973ccc35d14276627a67ac76b434452f23f9ed4d8aa3fbb01fdf285fc2","functions-info.html":"78ac80bf81da2e4f4a33f3b850faa86f0f58ec54a083d6c31da557907de0df87","rangetypes.html":"e4960abc7ce8e51d794f94f1e57b099d30b7f75dd7f2b23a960eef91f6291c33","rowtypes.html":"74f99e029c3a9edfd3e18810ba3c8cb66d3aada91eb67b86476560871e6617e9","sql-createdomain.html":"e94f927196de1b0ea1ce35cd4603c1f6f544439adcc0edf1c4222358e832245b"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_files":{"doc/src/sgml/datatype.sgml":"86328daa77e20d81d222376ec0306d9841a17104e436c08d138eb763aefb3700","src/include/catalog/pg_am.dat":"b3cb86b102a42fb0024cbd99779c9897afb40d12a71f5cc5a0e5aee7ff2f9969","src/include/catalog/pg_am.h":"3426799df799f32163fcc0765f43dbdb5e88e626acf31284fef9fc6014b69d8e","src/include/catalog/pg_cast.dat":"97911281ca2c81917394ccb2ec13367e37c6801fd461d5e1a3d2f28b911b46b2","src/include/catalog/pg_cast.h":"de585c7df687d698e7d1d100dce8a794ac9da52414ea48169191019178c8f053","src/include/catalog/pg_opclass.dat":"4ee7d3619a6aa106e1c0db55de903931c7d11b1c60ba053a022519c55f8ee668","src/include/catalog/pg_opclass.h":"9c218537806c8ef0398302faaca7f91315dfc1198c48706cebffb479b68defaf","src/include/catalog/pg_operator.dat":"5d35b9b2ef5f9797cc815263927ef8a12367fedace53e828b4e8b320e2a7f703","src/include/catalog/pg_operator.h":"621b18cfffe102413d79b746ce7a10f77fc60fdd097bac34c22b31070d3ee3c4","src/include/catalog/pg_opfamily.dat":"3b694879027b858f2ecf1fa1152b7e30c6e15a216ba99c2384291c30e9d52311","src/include/catalog/pg_opfamily.h":"e1f5fc8aebd3042df847455bf66bf755f768c2aa8a9b03d22f7ec8563eba59c0","src/include/catalog/pg_proc.dat":"1f934ce80d460159dda137714374a35f9896315ea2476709cbb4da13b38ef95a","src/include/catalog/pg_proc.h":"f7d59f07c5b95e2f3c7141762a0f576e8a3af7581ba54c27537f4d500472bea5","src/include/catalog/pg_range.dat":"5c2271f8e89e9378d1887204e5785060b77405b5f0ff3e6c719250c9c1dcfcc4","src/include/catalog/pg_range.h":"45546d952b5181f989bd9234721897fc2b37005c8e49ce2ddc156f26974c3ca4","src/include/catalog/pg_type.dat":"5f5887b75677cba2d4a1a0cfeb355df5ed91f85d385fac88bd8d7c605b3578f9","src/include/catalog/pg_type.h":"8fb198749fd82b6c1818a3c18455f226f66116fcfeb3d4959c65ce3fda22802e"},"source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"PostgreSQL 18 English manual","path":"datatype-net-types.html","sha256":"96846e641cc37727ddcd8b8a1aa0dbe33cd9787760a2b4efb0dcb9403d5be63f","url":"/docs/18/datatype-net-types.html"},{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"}]},"MeasuredEvidence":{}},"Text":{"Collection":"type","Key":"macaddr","SourceDatabase":"center","Version":"18","Locale":"en","Title":"macaddr","Summary":"MAC (Media Access Control) address","BodyHTML":"\u003cdiv id=\"DATATYPE-NET-TYPES\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2\u003e8.9. Network Address Types \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\u003cspan\u003ePostgreSQL\u003c/span\u003e offers data types to store IPv4, IPv6, and MAC addresses, as shown in \u003ca href=\"/docs/18/datatype-net-types.html#DATATYPE-NET-TYPES-TABLE\" rel=\"nofollow\"\u003eTable 8.21\u003c/a\u003e. 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 \u003ca href=\"/docs/18/functions-net.html\" rel=\"nofollow\"\u003eSection 9.12\u003c/a\u003e).\u003c/p\u003e\n\u003cdiv id=\"DATATYPE-NET-TYPES-TABLE\"\u003e\n\u003cp\u003e\u003cstrong\u003eTable 8.21. Network Address Types\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv\u003e\n\u003ctable\u003e\n\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eName\u003c/th\u003e\n\u003cth\u003eStorage Size\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003ecidr\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7 or 19 bytes\u003c/td\u003e\n\u003ctd\u003eIPv4 and IPv6 networks\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003einet\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7 or 19 bytes\u003c/td\u003e\n\u003ctd\u003eIPv4 and IPv6 hosts and networks\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003emacaddr\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e6 bytes\u003c/td\u003e\n\u003ctd\u003eMAC addresses\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003emacaddr8\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e8 bytes\u003c/td\u003e\n\u003ctd\u003eMAC addresses (EUI-64 format)\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr\u003e\n\u003cp\u003eWhen sorting \u003ccode\u003einet\u003c/code\u003e or \u003ccode\u003ecidr\u003c/code\u003e 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.\u003c/p\u003e\n\u003cdiv id=\"DATATYPE-INET\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e8.9.1. \u003ccode\u003einet\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode\u003einet\u003c/code\u003e type holds an IPv4 or IPv6 host address, and optionally its subnet, all in one field. The subnet is represented by the number of network address bits present in the host address (the \u003cspan\u003e“\u003cspan\u003enetmask\u003c/span\u003e”\u003c/span\u003e). If the netmask is 32 and the address is IPv4, then the value does not indicate a subnet, only a single host. In IPv6, the address length is 128 bits, so 128 bits specify a unique host address. Note that if you want to accept only networks, you should use the \u003ccode\u003ecidr\u003c/code\u003e type rather than \u003ccode\u003einet\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe input format for this type is \u003cem\u003e\u003ccode\u003eaddress/y\u003c/code\u003e\u003c/em\u003e where \u003cem\u003e\u003ccode\u003eaddress\u003c/code\u003e\u003c/em\u003e is an IPv4 or IPv6 address and \u003cem\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is the number of bits in the netmask. If the \u003cem\u003e\u003ccode\u003e/y\u003c/code\u003e\u003c/em\u003e portion is omitted, the netmask is taken to be 32 for IPv4 or 128 for IPv6, so the value represents just a single host. On display, the \u003cem\u003e\u003ccode\u003e/y\u003c/code\u003e\u003c/em\u003e portion is suppressed if the netmask specifies a single host.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"DATATYPE-CIDR\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e8.9.2. \u003ccode\u003ecidr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode\u003ecidr\u003c/code\u003e type holds an IPv4 or IPv6 network specification. Input and output formats follow Classless Internet Domain Routing conventions. The format for specifying networks is \u003cem\u003e\u003ccode\u003eaddress/y\u003c/code\u003e\u003c/em\u003e where \u003cem\u003e\u003ccode\u003eaddress\u003c/code\u003e\u003c/em\u003e is the network\u0026#39;s lowest address represented as an IPv4 or IPv6 address, and \u003cem\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is the number of bits in the netmask. If \u003cem\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is omitted, it is calculated using assumptions from the older classful network numbering system, except it will be at least large enough to include all of the octets written in the input. It is an error to specify a network address that has bits set to the right of the specified netmask.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"/docs/18/datatype-net-types.html#DATATYPE-NET-CIDR-TABLE\" rel=\"nofollow\"\u003eTable 8.22\u003c/a\u003e shows some examples.\u003c/p\u003e\n\u003cdiv id=\"DATATYPE-NET-CIDR-TABLE\"\u003e\n\u003cp\u003e\u003cstrong\u003eTable 8.22. \u003ccode\u003ecidr\u003c/code\u003e Type Input Examples\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv\u003e\n\u003ctable\u003e\n\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003e\u003ccode\u003ecidr\u003c/code\u003e Input\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003ecidr\u003c/code\u003e Output\u003c/th\u003e\n\u003cth\u003e\u003ccode\u003e\u003ccode\u003eabbrev(\u003ccode\u003ecidr\u003c/code\u003e)\u003c/code\u003e\u003c/code\u003e\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168/24\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.0/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168/25\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/25\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/25\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168.1\u003c/td\u003e\n\u003ctd\u003e192.168.1.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.1/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.0/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128.1\u003c/td\u003e\n\u003ctd\u003e128.1.0.0/16\u003c/td\u003e\n\u003ctd\u003e128.1/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128\u003c/td\u003e\n\u003ctd\u003e128.0.0.0/16\u003c/td\u003e\n\u003ctd\u003e128.0/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128.1.2\u003c/td\u003e\n\u003ctd\u003e128.1.2.0/24\u003c/td\u003e\n\u003ctd\u003e128.1.2/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1.2\u003c/td\u003e\n\u003ctd\u003e10.1.2.0/24\u003c/td\u003e\n\u003ctd\u003e10.1.2/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1\u003c/td\u003e\n\u003ctd\u003e10.1.0.0/16\u003c/td\u003e\n\u003ctd\u003e10.1/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10\u003c/td\u003e\n\u003ctd\u003e10.0.0.0/8\u003c/td\u003e\n\u003ctd\u003e10/8\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e2001:4f8:3:ba::/64\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba::/64\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba/64\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e::ffff:1.2.3.0/120\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/120\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3/120\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr\u003e\n\u003c/div\u003e\n\u003cdiv id=\"DATATYPE-INET-VS-CIDR\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e8.9.3. \u003ccode\u003einet\u003c/code\u003e vs. \u003ccode\u003ecidr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe essential difference between \u003ccode\u003einet\u003c/code\u003e and \u003ccode\u003ecidr\u003c/code\u003e data types is that \u003ccode\u003einet\u003c/code\u003e accepts values with nonzero bits to the right of the netmask, whereas \u003ccode\u003ecidr\u003c/code\u003e does not. For example, \u003ccode\u003e192.168.0.1/24\u003c/code\u003e is valid for \u003ccode\u003einet\u003c/code\u003e but not for \u003ccode\u003ecidr\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eIf you do not like the output format for \u003ccode\u003einet\u003c/code\u003e or \u003ccode\u003ecidr\u003c/code\u003e values, try the functions \u003ccode\u003ehost\u003c/code\u003e, \u003ccode\u003etext\u003c/code\u003e, and \u003ccode\u003eabbrev\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"DATATYPE-MACADDR\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e8.9.4. \u003ccode\u003emacaddr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode\u003emacaddr\u003c/code\u003e type stores MAC addresses, known for example from Ethernet card hardware addresses (although MAC addresses are used for other purposes as well). Input is accepted in the following formats:\u003c/p\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08:00:2b:01:02:03\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08-00-2b-01-02-03\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08002b:010203\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08002b-010203\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;0800.2b01.0203\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;0800-2b01-0203\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08002b010203\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cp\u003eThese examples all specify the same address. Upper and lower case is accepted for the digits \u003ccode\u003ea\u003c/code\u003e through \u003ccode\u003ef\u003c/code\u003e. Output is always in the first of the forms shown.\u003c/p\u003e\n\u003cp\u003eIEEE Standard 802-2001 specifies the second form shown (with hyphens) as the canonical form for MAC addresses, and specifies the first form (with colons) as used with bit-reversed, MSB-first notation, so that 08-00-2b-01-02-03 = 10:00:D4:80:40:C0. This convention is widely ignored nowadays, and it is relevant only for obsolete network protocols (such as Token Ring). PostgreSQL makes no provisions for bit reversal; all accepted formats use the canonical LSB order.\u003c/p\u003e\n\u003cp\u003eThe remaining five input formats are not part of any standard.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"DATATYPE-MACADDR8\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e8.9.5. \u003ccode\u003emacaddr8\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode\u003emacaddr8\u003c/code\u003e type stores MAC addresses in EUI-64 format, known for example from Ethernet card hardware addresses (although MAC addresses are used for other purposes as well). This type can accept both 6 and 8 byte length MAC addresses and stores them in 8 byte length format. MAC addresses given in 6 byte format will be stored in 8 byte length format with the 4th and 5th bytes set to FF and FE, respectively. Note that IPv6 uses a modified EUI-64 format where the 7th bit should be set to one after the conversion from EUI-48. The function \u003ccode\u003emacaddr8_set7bit\u003c/code\u003e is provided to make this change. Generally speaking, any input which is comprised of pairs of hex digits (on byte boundaries), optionally separated consistently by one of \u003ccode\u003e\u0026#39;:\u0026#39;\u003c/code\u003e, \u003ccode\u003e\u0026#39;-\u0026#39;\u003c/code\u003e or \u003ccode\u003e\u0026#39;.\u0026#39;\u003c/code\u003e, is accepted. The number of hex digits must be either 16 (8 bytes) or 12 (6 bytes). Leading and trailing whitespace is ignored. The following are examples of input formats that are accepted:\u003c/p\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08:00:2b:01:02:03:04:05\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08-00-2b-01-02-03-04-05\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08002b:0102030405\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08002b-0102030405\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;0800.2b01.0203.0405\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;0800-2b01-0203-0405\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08002b01:02030405\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003e\u0026#39;08002b0102030405\u0026#39;\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cp\u003eThese examples all specify the same address. Upper and lower case is accepted for the digits \u003ccode\u003ea\u003c/code\u003e through \u003ccode\u003ef\u003c/code\u003e. Output is always in the first of the forms shown.\u003c/p\u003e\n\u003cp\u003eThe last six input formats shown above are not part of any standard.\u003c/p\u003e\n\u003cp\u003eTo convert a traditional 48 bit MAC address in EUI-48 format to modified EUI-64 format to be included as the host portion of an IPv6 address, use \u003ccode\u003emacaddr8_set7bit\u003c/code\u003e as shown:\u003c/p\u003e\n\u003cpre\u003eSELECT macaddr8_set7bit(\u0026#39;08:00:2b:01:02:03\u0026#39;);\n\u003ccode\u003e\n    macaddr8_set7bit\n-------------------------\n 0a:00:2b:ff:fe:01:02:03\n(1 row)\n\u003c/code\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"6ef573925debe5c83b67b1b823e887f0be06ed3c3d7472dcdd96751ebc74370a","Payload":{"description":["MAC (Media Access Control) address"],"manual_html":"\u003cdiv class=\"sect1\" id=\"DATATYPE-NET-TYPES\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e8.9. Network Address Types \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e offers data types to store IPv4, IPv6, and MAC addresses, as shown in \u003ca class=\"xref\" href=\"/docs/18/datatype-net-types.html#DATATYPE-NET-TYPES-TABLE\" title=\"Table 8.21. Network Address Types\"\u003eTable 8.21\u003c/a\u003e. 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 \u003ca class=\"xref\" href=\"/docs/18/functions-net.html\" title=\"9.12. Network Address Functions and Operators\"\u003eSection 9.12\u003c/a\u003e).\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"DATATYPE-NET-TYPES-TABLE\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 8.21. Network Address Types\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eName\u003c/th\u003e\n\u003cth\u003eStorage Size\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7 or 19 bytes\u003c/td\u003e\n\u003ctd\u003eIPv4 and IPv6 networks\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003einet\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e7 or 19 bytes\u003c/td\u003e\n\u003ctd\u003eIPv4 and IPv6 hosts and networks\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003emacaddr\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e6 bytes\u003c/td\u003e\n\u003ctd\u003eMAC addresses\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"type\"\u003emacaddr8\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003e8 bytes\u003c/td\u003e\n\u003ctd\u003eMAC addresses (EUI-64 format)\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eWhen sorting \u003ccode class=\"type\"\u003einet\u003c/code\u003e or \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e 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.\u003c/p\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-INET\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.1. \u003ccode class=\"type\"\u003einet\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003einet\u003c/code\u003e type holds an IPv4 or IPv6 host address, and optionally its subnet, all in one field. The subnet is represented by the number of network address bits present in the host address (the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003enetmask\u003c/span\u003e”\u003c/span\u003e). If the netmask is 32 and the address is IPv4, then the value does not indicate a subnet, only a single host. In IPv6, the address length is 128 bits, so 128 bits specify a unique host address. Note that if you want to accept only networks, you should use the \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e type rather than \u003ccode class=\"type\"\u003einet\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe input format for this type is \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress/y\u003c/code\u003e\u003c/em\u003e where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress\u003c/code\u003e\u003c/em\u003e is an IPv4 or IPv6 address and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is the number of bits in the netmask. If the \u003cem class=\"replaceable\"\u003e\u003ccode\u003e/y\u003c/code\u003e\u003c/em\u003e portion is omitted, the netmask is taken to be 32 for IPv4 or 128 for IPv6, so the value represents just a single host. On display, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003e/y\u003c/code\u003e\u003c/em\u003e portion is suppressed if the netmask specifies a single host.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-CIDR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.2. \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e type holds an IPv4 or IPv6 network specification. Input and output formats follow Classless Internet Domain Routing conventions. The format for specifying networks is \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress/y\u003c/code\u003e\u003c/em\u003e where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaddress\u003c/code\u003e\u003c/em\u003e is the network's lowest address represented as an IPv4 or IPv6 address, and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is the number of bits in the netmask. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e is omitted, it is calculated using assumptions from the older classful network numbering system, except it will be at least large enough to include all of the octets written in the input. It is an error to specify a network address that has bits set to the right of the specified netmask.\u003c/p\u003e\n\u003cp\u003e\u003ca class=\"xref\" href=\"/docs/18/datatype-net-types.html#DATATYPE-NET-CIDR-TABLE\" title=\"Table 8.22. cidr Type Input Examples\"\u003eTable 8.22\u003c/a\u003e shows some examples.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"DATATYPE-NET-CIDR-TABLE\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 8.22. \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e Type Input Examples\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003e\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e Input\u003c/th\u003e\n\u003cth\u003e\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e Output\u003c/th\u003e\n\u003cth\u003e\u003ccode class=\"literal\"\u003e\u003ccode class=\"function\"\u003eabbrev(\u003ccode class=\"type\"\u003ecidr\u003c/code\u003e)\u003c/code\u003e\u003c/code\u003e\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003ctd\u003e192.168.100.128/25\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168/24\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.0/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168/25\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/25\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/25\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168.1\u003c/td\u003e\n\u003ctd\u003e192.168.1.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.1/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e192.168\u003c/td\u003e\n\u003ctd\u003e192.168.0.0/24\u003c/td\u003e\n\u003ctd\u003e192.168.0/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128.1\u003c/td\u003e\n\u003ctd\u003e128.1.0.0/16\u003c/td\u003e\n\u003ctd\u003e128.1/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128\u003c/td\u003e\n\u003ctd\u003e128.0.0.0/16\u003c/td\u003e\n\u003ctd\u003e128.0/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e128.1.2\u003c/td\u003e\n\u003ctd\u003e128.1.2.0/24\u003c/td\u003e\n\u003ctd\u003e128.1.2/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1.2\u003c/td\u003e\n\u003ctd\u003e10.1.2.0/24\u003c/td\u003e\n\u003ctd\u003e10.1.2/24\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1\u003c/td\u003e\n\u003ctd\u003e10.1.0.0/16\u003c/td\u003e\n\u003ctd\u003e10.1/16\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10\u003c/td\u003e\n\u003ctd\u003e10.0.0.0/8\u003c/td\u003e\n\u003ctd\u003e10/8\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003ctd\u003e10.1.2.3/32\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e2001:4f8:3:ba::/64\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba::/64\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba/64\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003ctd\u003e2001:4f8:3:ba:​2e0:81ff:fe22:d1f1/128\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e::ffff:1.2.3.0/120\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/120\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3/120\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003ctd\u003e::ffff:1.2.3.0/128\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-INET-VS-CIDR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.3. \u003ccode class=\"type\"\u003einet\u003c/code\u003e vs. \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe essential difference between \u003ccode class=\"type\"\u003einet\u003c/code\u003e and \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e data types is that \u003ccode class=\"type\"\u003einet\u003c/code\u003e accepts values with nonzero bits to the right of the netmask, whereas \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e does not. For example, \u003ccode class=\"literal\"\u003e192.168.0.1/24\u003c/code\u003e is valid for \u003ccode class=\"type\"\u003einet\u003c/code\u003e but not for \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eIf you do not like the output format for \u003ccode class=\"type\"\u003einet\u003c/code\u003e or \u003ccode class=\"type\"\u003ecidr\u003c/code\u003e values, try the functions \u003ccode class=\"function\"\u003ehost\u003c/code\u003e, \u003ccode class=\"function\"\u003etext\u003c/code\u003e, and \u003ccode class=\"function\"\u003eabbrev\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-MACADDR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.4. \u003ccode class=\"type\"\u003emacaddr\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003emacaddr\u003c/code\u003e type stores MAC addresses, known for example from Ethernet card hardware addresses (although MAC addresses are used for other purposes as well). Input is accepted in the following formats:\u003c/p\u003e\n\u003ctable class=\"simplelist\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08:00:2b:01:02:03'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08-00-2b-01-02-03'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b:010203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b-010203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800.2b01.0203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800-2b01-0203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b010203'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cp\u003eThese examples all specify the same address. Upper and lower case is accepted for the digits \u003ccode class=\"literal\"\u003ea\u003c/code\u003e through \u003ccode class=\"literal\"\u003ef\u003c/code\u003e. Output is always in the first of the forms shown.\u003c/p\u003e\n\u003cp\u003eIEEE Standard 802-2001 specifies the second form shown (with hyphens) as the canonical form for MAC addresses, and specifies the first form (with colons) as used with bit-reversed, MSB-first notation, so that 08-00-2b-01-02-03 = 10:00:D4:80:40:C0. This convention is widely ignored nowadays, and it is relevant only for obsolete network protocols (such as Token Ring). PostgreSQL makes no provisions for bit reversal; all accepted formats use the canonical LSB order.\u003c/p\u003e\n\u003cp\u003eThe remaining five input formats are not part of any standard.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-MACADDR8\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.9.5. \u003ccode class=\"type\"\u003emacaddr8\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThe \u003ccode class=\"type\"\u003emacaddr8\u003c/code\u003e type stores MAC addresses in EUI-64 format, known for example from Ethernet card hardware addresses (although MAC addresses are used for other purposes as well). This type can accept both 6 and 8 byte length MAC addresses and stores them in 8 byte length format. MAC addresses given in 6 byte format will be stored in 8 byte length format with the 4th and 5th bytes set to FF and FE, respectively. Note that IPv6 uses a modified EUI-64 format where the 7th bit should be set to one after the conversion from EUI-48. The function \u003ccode class=\"function\"\u003emacaddr8_set7bit\u003c/code\u003e is provided to make this change. Generally speaking, any input which is comprised of pairs of hex digits (on byte boundaries), optionally separated consistently by one of \u003ccode class=\"literal\"\u003e':'\u003c/code\u003e, \u003ccode class=\"literal\"\u003e'-'\u003c/code\u003e or \u003ccode class=\"literal\"\u003e'.'\u003c/code\u003e, is accepted. The number of hex digits must be either 16 (8 bytes) or 12 (6 bytes). Leading and trailing whitespace is ignored. The following are examples of input formats that are accepted:\u003c/p\u003e\n\u003ctable class=\"simplelist\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08:00:2b:01:02:03:04:05'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08-00-2b-01-02-03-04-05'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b:0102030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b-0102030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800.2b01.0203.0405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'0800-2b01-0203-0405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b01:02030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003e'08002b0102030405'\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cp\u003eThese examples all specify the same address. Upper and lower case is accepted for the digits \u003ccode class=\"literal\"\u003ea\u003c/code\u003e through \u003ccode class=\"literal\"\u003ef\u003c/code\u003e. Output is always in the first of the forms shown.\u003c/p\u003e\n\u003cp\u003eThe last six input formats shown above are not part of any standard.\u003c/p\u003e\n\u003cp\u003eTo convert a traditional 48 bit MAC address in EUI-48 format to modified EUI-64 format to be included as the host portion of an IPv6 address, use \u003ccode class=\"function\"\u003emacaddr8_set7bit\u003c/code\u003e as shown:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT macaddr8_set7bit('08:00:2b:01:02:03');\n\u003ccode class=\"computeroutput\"\u003e\n    macaddr8_set7bit\n-------------------------\n 0a:00:2b:ff:fe:01:02:03\n(1 row)\n\u003c/code\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e","related":[{"label":"pg_type catalog","url":"/wiki/catalog/pg_type/?v=18"},{"label":"pg_cast catalog","url":"/wiki/catalog/pg_cast/?v=18"},{"label":"pg_operator catalog","url":"/wiki/catalog/pg_operator/?v=18"},{"label":"pg_opclass catalog","url":"/wiki/catalog/pg_opclass/?v=18"},{"label":"Arrays","url":"/wiki/type/arrays/?v=18"},{"label":"brin index access method","url":"/wiki/indexam/brin/?v=18"},{"label":"btree index access method","url":"/wiki/indexam/btree/?v=18"},{"label":"hash index access method","url":"/wiki/indexam/hash/?v=18"}],"sections":[]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
