mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 02:52:13 +00:00
Bit more complicated example for isIPv4String
This commit is contained in:
parent
90ba831301
commit
c925e34e73
@ -267,7 +267,7 @@ SELECT toIPv6('127.0.0.1')
|
|||||||
|
|
||||||
## isIPv4String {#isipv4string}
|
## isIPv4String {#isipv4string}
|
||||||
|
|
||||||
Determines whether the input string is an IPv4 address or not. Also will return `0` if `string` is IPv6 address.
|
Determines whether the input string is an IPv4 address or not. If `string` is IPv6 address returns `0`.
|
||||||
|
|
||||||
**Syntax**
|
**Syntax**
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ isIPv4String(string)
|
|||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
- `1` if `string` is IPv4 address, `0` if not.
|
- `1` if `string` is IPv4 address, `0` otherwise.
|
||||||
|
|
||||||
Type: [UInt8](../../sql-reference/data-types/int-uint.md).
|
Type: [UInt8](../../sql-reference/data-types/int-uint.md).
|
||||||
|
|
||||||
@ -290,20 +290,22 @@ Type: [UInt8](../../sql-reference/data-types/int-uint.md).
|
|||||||
Query:
|
Query:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT isIPv4String('0.0.0.0');
|
SELECT addr, isIPv4String(addr) FROM ( SELECT ['0.0.0.0', '127.0.0.1', '::ffff:127.0.0.1'] AS addr ) ARRAY JOIN addr
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
``` text
|
``` text
|
||||||
┌─isIPv4String('0.0.0.0')─┐
|
┌─addr─────────────┬─isIPv4String(addr)─┐
|
||||||
│ 1 │
|
│ 0.0.0.0 │ 1 │
|
||||||
└─────────────────────────┘
|
│ 127.0.0.1 │ 1 │
|
||||||
|
│ ::ffff:127.0.0.1 │ 0 │
|
||||||
|
└──────────────────┴────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## isIPv6String {#isipv6string}
|
## isIPv6String {#isipv6string}
|
||||||
|
|
||||||
Determines whether the input string is an IPv6 address or not. Also will return `0` if `string` is IPv4 address.
|
Determines whether the input string is an IPv6 address or not. If `string` is IPv4 address returns `0`.
|
||||||
|
|
||||||
**Syntax**
|
**Syntax**
|
||||||
|
|
||||||
@ -317,7 +319,7 @@ isIPv6String(string)
|
|||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
- `1` if `string` is IPv6 address, `0` if not.
|
- `1` if `string` is IPv6 address, `0` otherwise.
|
||||||
|
|
||||||
Type: [UInt8](../../sql-reference/data-types/int-uint.md).
|
Type: [UInt8](../../sql-reference/data-types/int-uint.md).
|
||||||
|
|
||||||
@ -326,15 +328,18 @@ Type: [UInt8](../../sql-reference/data-types/int-uint.md).
|
|||||||
Query:
|
Query:
|
||||||
|
|
||||||
``` sql
|
``` sql
|
||||||
SELECT isIPv6String('::ffff:127.0.0.1');
|
SELECT addr, isIPv6String(addr) FROM ( SELECT ['::', '1111::ffff', '::ffff:127.0.0.1', '127.0.0.1'] AS addr ) ARRAY JOIN addr
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
``` text
|
``` text
|
||||||
┌─isIPv6String('::ffff:127.0.0.1')─┐
|
┌─addr─────────────┬─isIPv6String(addr)─┐
|
||||||
│ 1 │
|
│ :: │ 1 │
|
||||||
└──────────────────────────────────┘
|
│ 1111::ffff │ 1 │
|
||||||
|
│ ::ffff:127.0.0.1 │ 1 │
|
||||||
|
│ 127.0.0.1 │ 0 │
|
||||||
|
└──────────────────┴────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
[Original article](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) <!--hide-->
|
[Original article](https://clickhouse.tech/docs/en/query_language/functions/ip_address_functions/) <!--hide-->
|
||||||
|
Loading…
Reference in New Issue
Block a user