PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹9. 庘昄启淉嘩严媆誕嬉誕

9.11. 䘏䂩婄应庘昄启淉嘩严

臘9-31滆䴺庖埇傖䫘庯 cidrinet 䔇淉嘩严㔗淉嘩严 <<, <<=, >>, >>= 䫘庯敋臘床䘏寙劆垄傸埻蔄荏婴婻婄应䔇䘏䂩鄘彖媘䘖傂嘘婂橺鄘彖䇽劯彴桺噽婺婔婻䘏䂩鄘彖滇京庯埥崡婔婻誻滇埥崡婔婻䔇床䘏㔗

臘9-31. cidrinet 淉嘩严

淉嘩严柟誄冋床
<償庯inet '192.168.1.5' < inet '192.168.1.6'
<=償庯潡京庯inet '192.168.1.5' <= inet '192.168.1.5'
=京庯inet '192.168.1.5' = inet '192.168.1.5'
>=崓庯潡京庯inet '192.168.1.5' >= inet '192.168.1.5'
>崓庯inet '192.168.1.5' > inet '192.168.1.4'
<>婉京庯inet '192.168.1.5' <> inet '192.168.1.4'
<<寙劆庯inet '192.168.1.5' << inet '192.168.1/24'
<<=寙劆庯潡京庯inet '192.168.1/24' <<= inet '192.168.1/24'
>>寙劆inet '192.168.1/24' >> inet '192.168.1.5'
>>=寙劆潡京庯inet '192.168.1/24' >>= inet '192.168.1/24'
~嘉麂~ inet '192.168.1.6'
&嘉婯inet '192.168.1.6' & inet '0.0.0.255'
|嘉潡inet '192.168.1.6' | inet '0.0.0.255'
+inet '192.168.1.6' + 25
-inet '192.168.1.43' - 36
-inet '192.168.1.43' - inet '192.168.1.19'

臘9-32滆䴺庖欔橬埇傖䫘庯 cidrinet 䔇庘昄㔗庘昄 host, text, abbrev 婂襕滇婺庖柊冕埇锬䔇滆䴺湚嚟䫘䔇㔗

臘9-32. cidrinet 庘昄

庘昄誫啂䌂傋柟誄冋床䂷悩
abbrev(inet)text䚷喍滆䴺湚嚟桺橸abbrev(inet '10.1.0.0/16')10.1.0.0/16
abbrev(cidr)text䚷喍滆䴺湚嚟桺橸abbrev(cidr '10.1.0.0/16')10.1/16
broadcast(inet)inet䘏䂩幪携婄应broadcast('192.168.1.5/24')192.168.1.255/24
family(inet)int檘埡婄应斟(4 婺IPv46 婺IPv6)family('::1')6
host(inet)text儖婂橺婄应䌂傋檘庺婺桺橸host('192.168.1.5/24')192.168.1.5
hostmask(inet)inet婺䘏䂩悇锹婂橺毷乕hostmask('192.168.23.20/30')0.0.0.3
masklen(inet)int檘埡床䘏毷乕阪庥masklen('192.168.1.5/24')24
netmask(inet)inet婺䘏䂩悇锹床䘏毷乕netmask('192.168.1.5/24')255.255.255.0
network(inet)cidr檘埡婄应䔇䘏䂩鄘彖network('192.168.1.5/24')192.168.1.0/24
set_masklen(inet, int)inetinet 昄唚螆䘞床䘏毷乕阪庥set_masklen('192.168.1.5/24', 16)192.168.1.5/16
set_masklen(cidr, int)cidrcidr 昄唚螆䘞床䘏毷乕阪庥set_masklen('192.168.1.0/24'::cidr, 16)192.168.0.0/16
text(inet)text 檪 IP 婄应启毷乕阪庥檘埡婺桺橸text(inet '192.168.1.5')192.168.1.5/32

傂嘘 cidr 唚鄘脘崘赆锊劆潡滯䇞䔇蘸扵婺 inet 唚啹溴婪誄脘崘淉嘩 inet 唚䔇庘昄幘劯湙脘崘淉嘩 cidr 唚㔗蔯儖昊底淉嘩 inetcidr 䔇庘昄剘䋸彖锫嚔滇啹婺垄傸䔇臯婺婉劯㔗inet 唚幘埇傖蘸扵婺 cidr 唚溴施床䘏毷乕埿冓䔇欔橬嘉鄘儖方弄䔇蘸扵婺镽傖诙冖婔婻橬昽䔇 cidr 唚㔗埥崡嘹誻埇傖嘪䫘婩蓇䔇䌂傋蘸扵臺濘儖婔婻桺橸庖严婾蘸扵婺 inetcidr 唚㔗冋套inet(expression)colname::cidr

臘9-33滆䴺庖埇傖䫘庯 macaddr 䌂傋䔇庘昄㔗庘昄 trunc(macaddr) 誫啂婔婻 MAC 婄应臖婄应䔇橔劯婬婻庖誗螆䘞婺镽㔗認湙埇傖檪嬷婋䔇嬉䚔婯婔婻彽锹嘖䕩噿蕫㔗

臘9-33. macaddr 庘昄

庘昄誫啂䌂傋柟誄冋床䂷悩
trunc(macaddr)macaddr檪劯婬婻庖誗䘞婺镽trunc(macaddr '12:34:56:78:90:ab')12:34:56:00:00:00

macaddr 䌂傋誻櫇毕湺庖噿係淉嘩严(>, <= 京)䫘庯臉濘毐废㔗


劯锔饡釕嬉誕
庹嘘庘昄启淉嘩严婪婔亓废彖淉嘩庘昄