|
| 1 | +QUERY: DROP TABLE INET_TBL; |
| 2 | +ERROR: Relation inet_tbl Does Not Exist! |
| 3 | +QUERY: CREATE TABLE INET_TBL (c cidr, i inet); |
| 4 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.226/24'); |
| 5 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/24', '192.168.1.226'); |
| 6 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8'); |
| 7 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('10.0.0.0', '10.1.2.3/8'); |
| 8 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('10.1.2.3', '10.1.2.3/32'); |
| 9 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('10.1.2', '10.1.2.3/24'); |
| 10 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('10.1', '10.1.2.3/16'); |
| 11 | +QUERY: INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8'); |
| 12 | +QUERY: SELECT '' as eight, c as cidr, i as inet FROM INET_TBL; |
| 13 | +eight|cidr |inet |
| 14 | +-----+------------+---------------- |
| 15 | + |192.168.1/24|192.168.1.226/24 |
| 16 | + |192.168.1/24|192.168.1.226 |
| 17 | + |10/8 |10.1.2.3/8 |
| 18 | + |10.0.0.0/32 |10.1.2.3/8 |
| 19 | + |10.1.2.3/32 |10.1.2.3 |
| 20 | + |10.1.2/24 |10.1.2.3/24 |
| 21 | + |10.1/16 |10.1.2.3/16 |
| 22 | + |10/8 |10.1.2.3/8 |
| 23 | +(8 rows) |
| 24 | + |
| 25 | +QUERY: SELECT '' as eight, i as inet, host(i) FROM INET_TBL; |
| 26 | +eight|inet | host |
| 27 | +-----+----------------+------------- |
| 28 | + |192.168.1.226/24|192.168.1.226 |
| 29 | + |192.168.1.226 |192.168.1.226 |
| 30 | + |10.1.2.3/8 | 10.1.2.3 |
| 31 | + |10.1.2.3/8 | 10.1.2.3 |
| 32 | + |10.1.2.3 | 10.1.2.3 |
| 33 | + |10.1.2.3/24 | 10.1.2.3 |
| 34 | + |10.1.2.3/16 | 10.1.2.3 |
| 35 | + |10.1.2.3/8 | 10.1.2.3 |
| 36 | +(8 rows) |
| 37 | + |
| 38 | +QUERY: SELECT '' as eight, c as cidr, broadcast(c), |
| 39 | + i as inet, broadcast(i) FROM INET_TBL; |
| 40 | +eight|cidr | broadcast|inet | broadcast |
| 41 | +-----+------------+---------------+----------------+--------------- |
| 42 | + |192.168.1/24| 192.168.1.255|192.168.1.226/24| 192.168.1.255 |
| 43 | + |192.168.1/24| 192.168.1.255|192.168.1.226 |255.255.255.255 |
| 44 | + |10/8 | 10.255.255.255|10.1.2.3/8 | 10.255.255.255 |
| 45 | + |10.0.0.0/32 |255.255.255.255|10.1.2.3/8 | 10.255.255.255 |
| 46 | + |10.1.2.3/32 |255.255.255.255|10.1.2.3 |255.255.255.255 |
| 47 | + |10.1.2/24 | 10.1.2.255|10.1.2.3/24 | 10.1.2.255 |
| 48 | + |10.1/16 | 10.1.255.255|10.1.2.3/16 | 10.1.255.255 |
| 49 | + |10/8 | 10.255.255.255|10.1.2.3/8 | 10.255.255.255 |
| 50 | +(8 rows) |
| 51 | + |
| 52 | +QUERY: SELECT '' as eight, c as cidr, network(c) as "network(cidr)", |
| 53 | + i as inet, network(i) as "network(inet)" FROM INET_TBL; |
| 54 | +eight|cidr |network(cidr)|inet |network(inet) |
| 55 | +-----+------------+-------------+----------------+------------- |
| 56 | + |192.168.1/24| 0.1.168.192|192.168.1.226/24| 0.1.168.192 |
| 57 | + |192.168.1/24| 0.1.168.192|192.168.1.226 |226.1.168.192 |
| 58 | + |10/8 | 0.0.0.10|10.1.2.3/8 | 0.0.0.10 |
| 59 | + |10.0.0.0/32 | 0.0.0.10|10.1.2.3/8 | 0.0.0.10 |
| 60 | + |10.1.2.3/32 | 3.2.1.10|10.1.2.3 | 3.2.1.10 |
| 61 | + |10.1.2/24 | 0.2.1.10|10.1.2.3/24 | 0.2.1.10 |
| 62 | + |10.1/16 | 0.0.1.10|10.1.2.3/16 | 0.0.1.10 |
| 63 | + |10/8 | 0.0.0.10|10.1.2.3/8 | 0.0.0.10 |
| 64 | +(8 rows) |
| 65 | + |
| 66 | +QUERY: SELECT '' as eight, c as cidr, masklen(c) as "masklen(cidr)", |
| 67 | + i as inet, masklen(i) as "masklen(inet)" FROM INET_TBL; |
| 68 | +eight|cidr |masklen(cidr)|inet |masklen(inet) |
| 69 | +-----+------------+-------------+----------------+------------- |
| 70 | + |192.168.1/24| 24|192.168.1.226/24| 24 |
| 71 | + |192.168.1/24| 24|192.168.1.226 | 32 |
| 72 | + |10/8 | 8|10.1.2.3/8 | 8 |
| 73 | + |10.0.0.0/32 | 32|10.1.2.3/8 | 8 |
| 74 | + |10.1.2.3/32 | 32|10.1.2.3 | 32 |
| 75 | + |10.1.2/24 | 24|10.1.2.3/24 | 24 |
| 76 | + |10.1/16 | 16|10.1.2.3/16 | 16 |
| 77 | + |10/8 | 8|10.1.2.3/8 | 8 |
| 78 | +(8 rows) |
| 79 | + |
| 80 | +QUERY: SELECT '' as two, c as cidr, masklen(c) as "masklen(cidr)", |
| 81 | + i as inet, masklen(i) as "masklen(inet)" FROM INET_TBL |
| 82 | + WHERE masklen(c) <= 8; |
| 83 | +two|cidr|masklen(cidr)|inet |masklen(inet) |
| 84 | +---+----+-------------+----------+------------- |
| 85 | + |10/8| 8|10.1.2.3/8| 8 |
| 86 | + |10/8| 8|10.1.2.3/8| 8 |
| 87 | +(2 rows) |
| 88 | + |
| 89 | +QUERY: SELECT '' as six, c as cidr, i as inet FROM INET_TBL |
| 90 | + WHERE c = i; |
| 91 | +six|cidr |inet |
| 92 | +---+------------+---------------- |
| 93 | + |192.168.1/24|192.168.1.226/24 |
| 94 | + |10/8 |10.1.2.3/8 |
| 95 | + |10.1.2.3/32 |10.1.2.3 |
| 96 | + |10.1.2/24 |10.1.2.3/24 |
| 97 | + |10.1/16 |10.1.2.3/16 |
| 98 | + |10/8 |10.1.2.3/8 |
| 99 | +(6 rows) |
| 100 | + |
0 commit comments