mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
add documentation about IPv6CIDRtoIPv6Range and IPv4CIDRtoIPv4Range functions in english
This commit is contained in:
parent
efd780f20d
commit
24b0e9cc51
@ -147,4 +147,49 @@ SELECT
|
|||||||
└─────────────────────────────────────┴─────────────────────┘
|
└─────────────────────────────────────┴─────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## IPv4CIDRtoIPv4Range(ipv4, cidr),
|
||||||
|
|
||||||
|
Accepts a UInt32 value interpreted as an IPv4 address in big endian and an UInt8 value containing the CIDR. Return a tuple with two UInt32 interpreted as an IPv4 address in big endian containing the lower range and the higher range of the subnet.
|
||||||
|
|
||||||
|
|
||||||
|
```sql
|
||||||
|
WITH
|
||||||
|
IPv4StringToNum('192.168.5.2') AS ipv4,
|
||||||
|
IPv4CIDRtoIPv4Range(ipv4, 16) AS ip_range
|
||||||
|
SELECT
|
||||||
|
IPv4CIDRtoIPv4Range(ipv4, 16),
|
||||||
|
IPv4NumToString(ip_range.1) AS lower_range,
|
||||||
|
IPv4NumToString(ip_range.2) AS higher_range
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─IPv4CIDRtoIPv4Range(ipv4, 16)─┬─lower_range─┬─higher_range────┐
|
||||||
|
│ (3232235520,3232301055) │ 192.168.0.0 │ 192.168.255.255 │
|
||||||
|
└───────────────────────────────┴─────────────┴─────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## IPv6CIDRtoIPv6Range(ipv6, cidr),
|
||||||
|
|
||||||
|
Accepts a FixedString(16) value containing the IPv6 address in binary format and an UInt8 value containing the CIDR. Return a tuple with two FixedString(16) containing the lower range and the higher range of the subnet.
|
||||||
|
|
||||||
|
|
||||||
|
```sql
|
||||||
|
WITH
|
||||||
|
IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001') AS ipv6,
|
||||||
|
IPv6CIDRtoIPv6Range(ipv6, 32) AS ip_range
|
||||||
|
SELECT
|
||||||
|
IPv6NumToString(ip_range.1) AS lower_range,
|
||||||
|
IPv6NumToString(ip_range.2) AS higher_range
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─lower_range─┬─higher_range───────────────────────────┐
|
||||||
|
│ 2001:db8:: │ 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff │
|
||||||
|
└─────────────┴────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
[Original article](https://clickhouse.yandex/docs/en/query_language/functions/ip_address_functions/) <!--hide-->
|
[Original article](https://clickhouse.yandex/docs/en/query_language/functions/ip_address_functions/) <!--hide-->
|
||||||
|
Loading…
Reference in New Issue
Block a user