Add the example

Добавил примеры.
This commit is contained in:
Dmitriy 2021-08-21 23:26:27 +03:00
parent 7887f3892b
commit eeec8004e8

View File

@ -2240,6 +2240,8 @@ Type: [Array](../../sql-reference/data-types/array.md)([String](../../sql-refere
Returns the ID of the current query, which can be used instantly in other queries. Other parameters of a query can be extracted from the [system.query_log](../../operations/system-tables/query_log.md) table via `query_id`.
In contrast to [initialQueryID](#initial-query-id) function `queryID` can return different results on shards (see example). And then the server will argue that constant column has different values.
**Syntax**
``` sql
@ -2252,10 +2254,22 @@ queryID()
Type: [String](../../sql-reference/data-types/string.md)
**Example**
In this example the result of the query will be three different values, one of which will match the `initial_query_id` for this query.
Query:
``` sql
SELECT queryID() FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp');
```
## initialQueryID {#initial-query-id}
Returns the ID of the initial current query, which can be used instantly in other queries. Other parameters of a query can be extracted from the [system.query_log](../../operations/system-tables/query_log.md) table via `initial_query_id`.
In contrast to [queryID](#query-id) function `initialQueryID` returns same results on shards (see example).
**Syntax**
``` sql
@ -2267,3 +2281,13 @@ initialQueryID()
- The ID of the initial current query.
Type: [String](../../sql-reference/data-types/string.md)
**Example**
In this example the result of the query will be three same values.
Query:
``` sql
SELECT initialQueryID() FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp');
```