cidr和inet操作符
操作符<<,<<=,>>,>>=对子网包含进行测试。它们只考虑两个地址的网络部分(忽略任何主机部分),然后判断其中一个网络是等于另外一个网络,还是另外一个网络的子网。
<
描述:小于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.5' < inet '192.168.1.6' AS RESULT; result -------- t (1 row) |
<=
描述:小于或等于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.5' <= inet '192.168.1.5' AS RESULT; result -------- t (1 row) |
=
描述:等于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.5' = inet '192.168.1.5' AS RESULT; result -------- t (1 row) |
>=
描述:大于或等于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.5' >= inet '192.168.1.5' AS RESULT; result -------- t (1 row) |
>
描述:大于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.5' > inet '192.168.1.4' AS RESULT; result -------- t (1 row) |
<>
描述:不等于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.5' <> inet '192.168.1.4' AS RESULT; result -------- t (1 row) |
<<
描述:包含于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.5' << inet '192.168.1/24' AS RESULT; result -------- t (1 row) |
<<=
描述:包含于或等于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1/24' <<= inet '192.168.1/24' AS RESULT; result -------- t (1 row) |
>>
描述:包含
示例:
1 2 3 4 5 |
SELECT inet '192.168.1/24' >> inet '192.168.1.5' AS RESULT; result -------- t (1 row) |
>>=
描述:包含或等于
示例:
1 2 3 4 5 |
SELECT inet '192.168.1/24' >>= inet '192.168.1/24' AS RESULT; result -------- t (1 row) |
~
描述:位非
示例:
1 2 3 4 5 |
SELECT ~ inet '192.168.1.6' AS RESULT; result --------------- 63.87.254.249 (1 row) |
&
描述:两个网络地址的每一位都进行“与”操作。
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.6' & inet '10.0.0.0' AS RESULT; result --------- 0.0.0.0 (1 row) |
|
描述:两个网络地址的每一位都进行“或”操作。
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.6' | inet '10.0.0.0' AS RESULT; result ------------- 202.168.1.6 (1 row) |
+
描述:加
示例:
1 2 3 4 5 |
SELECT inet '192.168.1.6' + 25 AS RESULT; result -------------- 192.168.1.31 (1 row) |
-
描述:减
示例:
1 2 3 4 5 6 7 8 9 10 |
SELECT inet '192.168.1.43' - 36 AS RESULT; result ------------- 192.168.1.7 (1 row) SELECT inet '192.168.1.43' - inet '192.168.1.19' AS RESULT; result -------- 24 (1 row) |