diff --git a/docs/en/operations/settings/settings.md b/docs/en/operations/settings/settings.md index 98ccdab0c2e..4fc5fad7aa9 100644 --- a/docs/en/operations/settings/settings.md +++ b/docs/en/operations/settings/settings.md @@ -2460,7 +2460,7 @@ Default value: `0`. ## union_default_mode {#union-default-mode} -Sets a special mode for combining `SELECT` query results using the [UNION](../../sql-reference/statements/select/union-all.md) expression. +Sets a mode for combining `SELECT` query results. The setting is only used when shared with [UNION](../../sql-reference/statements/select/union.md) without explicitly specifying the `UNION ALL` or `UNION DISTINCT`. Possible values: @@ -2470,53 +2470,6 @@ Possible values: Default value: `'DISTINCT'`. -**Example of using the 'DISTINCT' value** - -Query: - -```sql -SET union_default_mode = 'DISTINCT'; -SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; -``` - -Result: - -```text -┌─1─┐ -│ 1 │ -└───┘ -┌─1─┐ -│ 2 │ -└───┘ -┌─1─┐ -│ 3 │ -└───┘ -``` - -**Example of using the 'ALL' value** - -Query: - -```sql -SET union_default_mode = 'ALL'; -SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; -``` - -Result: - -```text -┌─1─┐ -│ 1 │ -└───┘ -┌─1─┐ -│ 2 │ -└───┘ -┌─1─┐ -│ 2 │ -└───┘ -┌─1─┐ -│ 3 │ -└───┘ -``` +See examples in [UNION](../../sql-reference/statements/select/union.md). [Original article](https://clickhouse.tech/docs/en/operations/settings/settings/) diff --git a/docs/en/sql-reference/statements/select/index.md b/docs/en/sql-reference/statements/select/index.md index 60c769c4660..ed69198ed4d 100644 --- a/docs/en/sql-reference/statements/select/index.md +++ b/docs/en/sql-reference/statements/select/index.md @@ -46,7 +46,7 @@ Specifics of each optional clause are covered in separate sections, which are li - [SELECT clause](#select-clause) - [DISTINCT clause](../../../sql-reference/statements/select/distinct.md) - [LIMIT clause](../../../sql-reference/statements/select/limit.md) -- [UNION clause](../../../sql-reference/statements/select/union-all.md) +- [UNION clause](../../../sql-reference/statements/select/union.md) - [INTO OUTFILE clause](../../../sql-reference/statements/select/into-outfile.md) - [FORMAT clause](../../../sql-reference/statements/select/format.md) diff --git a/docs/en/sql-reference/statements/select/union-all.md b/docs/en/sql-reference/statements/select/union.md similarity index 51% rename from docs/en/sql-reference/statements/select/union-all.md rename to docs/en/sql-reference/statements/select/union.md index 85c50450273..099c680d9a7 100644 --- a/docs/en/sql-reference/statements/select/union-all.md +++ b/docs/en/sql-reference/statements/select/union.md @@ -2,7 +2,7 @@ toc_title: UNION --- -# UNION ALL Clause {#union-all-clause} +# UNION Clause {#union-clause} You can use `UNION ALL` to combine any number of `SELECT` queries by extending their results. Example: @@ -25,16 +25,55 @@ Type casting is performed for unions. For example, if two queries being combined Queries that are parts of `UNION ALL` can’t be enclosed in round brackets. [ORDER BY](../../../sql-reference/statements/select/order-by.md) and [LIMIT](../../../sql-reference/statements/select/limit.md) are applied to separate queries, not to the final result. If you need to apply a conversion to the final result, you can put all the queries with `UNION ALL` in a subquery in the [FROM](../../../sql-reference/statements/select/from.md) clause. -# UNION DISTINCT Clause {#union-distinct-clause} +By default, `UNION` has the same behavior as `UNION DISTINCT`. The difference between `UNION ALL` and `UNION DISTINCT` is that `UNION DISTINCT` will do a distinct transform for union result, it is equivalent to `SELECT DISTINCT` from a subquery containing `UNION ALL`. -The difference between `UNION ALL` and `UNION DISTINCT` is that `UNION DISTINCT` will do a distinct transform for union result, it is equivalent to `SELECT DISTINCT` from a subquery containing `UNION ALL`. +If you use `UNION` without explicitly specifying `UNION ALL` or `UNION DISTINCT`, you can specify the union mode using the [union_default_mode](../../../operations/settings/settings.md#union-default-mode) setting. The setting values can be `ALL`, `DISTINCT` or an empty string. However, if you use `UNION` with `union_default_mode` setting to empty string, it will throw an exception. The following examples demonstrate the results of queries with different values setting. -# UNION Clause {#union-clause} +Query: -By default, `UNION` has the same behavior as `UNION DISTINCT`, but you can specify union mode by [union_default_mode](../../../operations/settings/settings.md#union-default-mode) setting, values can be `ALL`, `DISTINCT` or an empty string. However, if you use `UNION` with `union_default_mode` setting to empty string, it will throw an exception. +```sql +SET union_default_mode = 'DISTINCT'; +SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; +``` -## Implementation Details {#implementation-details} +Result: + +```text +┌─1─┐ +│ 1 │ +└───┘ +┌─1─┐ +│ 2 │ +└───┘ +┌─1─┐ +│ 3 │ +└───┘ +``` + +Query: + +```sql +SET union_default_mode = 'ALL'; +SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; +``` + +Result: + +```text +┌─1─┐ +│ 1 │ +└───┘ +┌─1─┐ +│ 2 │ +└───┘ +┌─1─┐ +│ 2 │ +└───┘ +┌─1─┐ +│ 3 │ +└───┘ +``` Queries that are parts of `UNION/UNION ALL/UNION DISTINCT` can be run simultaneously, and their results can be mixed together. -[Original article](https://clickhouse.tech/docs/en/sql-reference/statements/select/union-all/) +[Original article](https://clickhouse.tech/docs/en/sql-reference/statements/select/union/) diff --git a/docs/es/sql-reference/statements/select/index.md b/docs/es/sql-reference/statements/select/index.md index a5ff9820a2b..653f737b1d0 100644 --- a/docs/es/sql-reference/statements/select/index.md +++ b/docs/es/sql-reference/statements/select/index.md @@ -44,7 +44,7 @@ Los detalles de cada cláusula opcional se cubren en secciones separadas, que se - [Cláusula HAVING](having.md) - [Cláusula SELECT](#select-clause) - [Cláusula LIMIT](limit.md) -- [UNION ALL cláusula](union-all.md) +- [UNION ALL cláusula](union.md) ## SELECT Cláusula {#select-clause} diff --git a/docs/es/sql-reference/statements/select/union-all.md b/docs/es/sql-reference/statements/select/union.md similarity index 97% rename from docs/es/sql-reference/statements/select/union-all.md rename to docs/es/sql-reference/statements/select/union.md index b2b45ba770e..d3aec34ba4b 100644 --- a/docs/es/sql-reference/statements/select/union-all.md +++ b/docs/es/sql-reference/statements/select/union.md @@ -3,7 +3,7 @@ machine_translated: true machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd --- -# UNION ALL Cláusula {#union-all-clause} +# UNION Cláusula {#union-clause} Usted puede utilizar `UNION ALL` combinar cualquier número de `SELECT` consultas extendiendo sus resultados. Ejemplo: diff --git a/docs/fa/sql-reference/statements/select/index.md b/docs/fa/sql-reference/statements/select/index.md index 2ab3fea2ff1..90541b80636 100644 --- a/docs/fa/sql-reference/statements/select/index.md +++ b/docs/fa/sql-reference/statements/select/index.md @@ -44,7 +44,7 @@ SELECT [DISTINCT] expr_list - [داشتن بند](having.md) - [انتخاب بند](#select-clause) - [بند محدود](limit.md) -- [اتحادیه همه بند](union-all.md) +- [اتحادیه همه بند](union.md) ## انتخاب بند {#select-clause} diff --git a/docs/fa/sql-reference/statements/select/union-all.md b/docs/fa/sql-reference/statements/select/union.md similarity index 97% rename from docs/fa/sql-reference/statements/select/union-all.md rename to docs/fa/sql-reference/statements/select/union.md index 3c4fe5c1546..03d723e2338 100644 --- a/docs/fa/sql-reference/statements/select/union-all.md +++ b/docs/fa/sql-reference/statements/select/union.md @@ -3,7 +3,7 @@ machine_translated: true machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd --- -# اتحادیه همه بند {#union-all-clause} +# اتحادیه همه بند {#union-clause} شما می توانید استفاده کنید `UNION ALL` برای ترکیب هر تعداد از `SELECT` نمایش داده شد با گسترش نتایج خود را. مثال: diff --git a/docs/fr/sql-reference/statements/select/index.md b/docs/fr/sql-reference/statements/select/index.md index 5073469e651..1d53ae80eb4 100644 --- a/docs/fr/sql-reference/statements/select/index.md +++ b/docs/fr/sql-reference/statements/select/index.md @@ -44,7 +44,7 @@ Spécificités de chaque clause facultative, sont couverts dans des sections dis - [Clause HAVING](having.md) - [Clause SELECT](#select-clause) - [Clause LIMIT](limit.md) -- [Clause UNION ALL](union-all.md) +- [Clause UNION ALL](union.md) ## Clause SELECT {#select-clause} diff --git a/docs/fr/sql-reference/statements/select/union-all.md b/docs/fr/sql-reference/statements/select/union.md similarity index 97% rename from docs/fr/sql-reference/statements/select/union-all.md rename to docs/fr/sql-reference/statements/select/union.md index 63e9987965f..9ae65ebcf72 100644 --- a/docs/fr/sql-reference/statements/select/union-all.md +++ b/docs/fr/sql-reference/statements/select/union.md @@ -3,7 +3,7 @@ machine_translated: true machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd --- -# Clause UNION ALL {#union-all-clause} +# Clause UNION ALL {#union-clause} Vous pouvez utiliser `UNION ALL` à combiner `SELECT` requêtes en étendant leurs résultats. Exemple: diff --git a/docs/ja/sql-reference/statements/select/union-all.md b/docs/ja/sql-reference/statements/select/union-all.md deleted file mode 120000 index 837caae2698..00000000000 --- a/docs/ja/sql-reference/statements/select/union-all.md +++ /dev/null @@ -1 +0,0 @@ -../../../../en/sql-reference/statements/select/union-all.md \ No newline at end of file diff --git a/docs/ja/sql-reference/statements/select/union.md b/docs/ja/sql-reference/statements/select/union.md new file mode 100644 index 00000000000..0eb8db0be7a --- /dev/null +++ b/docs/ja/sql-reference/statements/select/union.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/union.md \ No newline at end of file diff --git a/docs/ru/operations/settings/settings.md b/docs/ru/operations/settings/settings.md index d94f7ddfae8..00f59d9ce48 100644 --- a/docs/ru/operations/settings/settings.md +++ b/docs/ru/operations/settings/settings.md @@ -2326,7 +2326,7 @@ SELECT number FROM numbers(3) FORMAT JSONEachRow; ## union_default_mode {#union-default-mode} -Устанавливает особый режим объединения результатов `SELECT` запросов, используя выражение [UNION](../../sql-reference/statements/select/union-all.md). +Устанавливает режим объединения результатов `SELECT` запросов. Настройка используется только при совместном использовании с [UNION](../../sql-reference/statements/select/union.md) без явного указания `UNION ALL` или `UNION DISTINCT`. Возможные значения: @@ -2336,53 +2336,6 @@ SELECT number FROM numbers(3) FORMAT JSONEachRow; Значение по умолчанию: `'DISTINCT'`. -**Пример использования 'DISTINCT' в качестве значения настройки** - -Запрос: - -```sql -SET union_default_mode = 'DISTINCT'; -SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; -``` - -Результат: - -```text -┌─1─┐ -│ 1 │ -└───┘ -┌─1─┐ -│ 2 │ -└───┘ -┌─1─┐ -│ 3 │ -└───┘ -``` - -**Пример использования 'ALL' в качестве значения настройки** - -Запрос: - -```sql -SET union_default_mode = 'ALL'; -SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; -``` - -Результат: - -```text -┌─1─┐ -│ 1 │ -└───┘ -┌─1─┐ -│ 2 │ -└───┘ -┌─1─┐ -│ 2 │ -└───┘ -┌─1─┐ -│ 3 │ -└───┘ -``` +Смотрите примеры в разделе [UNION](../../sql-reference/statements/select/union.md). [Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/settings/) diff --git a/docs/ru/sql-reference/statements/select/index.md b/docs/ru/sql-reference/statements/select/index.md index c2e05f05079..bf4ae44a6f1 100644 --- a/docs/ru/sql-reference/statements/select/index.md +++ b/docs/ru/sql-reference/statements/select/index.md @@ -44,7 +44,7 @@ SELECT [DISTINCT] expr_list - [Секция SELECT](#select-clause) - [Секция DISTINCT](distinct.md) - [Секция LIMIT](limit.md) -- [Секция UNION ALL](union-all.md) +- [Секция UNION ALL](union.md) - [Секция INTO OUTFILE](into-outfile.md) - [Секция FORMAT](format.md) diff --git a/docs/ru/sql-reference/statements/select/union-all.md b/docs/ru/sql-reference/statements/select/union.md similarity index 53% rename from docs/ru/sql-reference/statements/select/union-all.md rename to docs/ru/sql-reference/statements/select/union.md index 72fc7299b30..4d7d96a23db 100644 --- a/docs/ru/sql-reference/statements/select/union-all.md +++ b/docs/ru/sql-reference/statements/select/union.md @@ -1,8 +1,8 @@ --- -toc_title: UNION ALL +toc_title: UNION --- -# Секция UNION ALL {#union-all-clause} +# Секция UNION {#union-clause} Вы можете использовать `UNION ALL` чтобы объединить любое количество `SELECT` запросы путем расширения их результатов. Пример: @@ -25,16 +25,55 @@ SELECT CounterID, 2 AS table, sum(Sign) AS c Запросы, которые являются частью `UNION ALL` не могут быть заключен в круглые скобки. [ORDER BY](order-by.md) и [LIMIT](limit.md) применяются к отдельным запросам, а не к конечному результату. Если вам нужно применить преобразование к конечному результату, вы можете разместить все объединенные с помощью `UNION ALL` запросы в подзапрос в секции [FROM](from.md). -# Секция UNION DISTINCT {#union-distinct-clause} +По умолчанию, `UNION` ведет себя так же, как и `UNION DISTINCT`. Разница между `UNION ALL` и `UNION DISTINCT` в том, что `UNION DISTINCT` выполняет явное преобразование для результата объединения. Это равнозначно выражению `SELECT DISTINCT` из подзапроса, содержащего `UNION ALL`. -Разница между `UNION ALL` и `UNION DISTINCT` в том, что `UNION DISTINCT` выполняет явное преобразование для результата объединения. Это равнозначно выражению `SELECT DISTINCT` из подзапроса, содержащего `UNION ALL`. +Если используете `UNION` без явного указания `UNION ALL` или `UNION DISTINCT`, то вы можете указать режим объединения с помощью настройки [union_default_mode](../../../operations/settings/settings.md#union-default-mode), значениями которой могут быть `ALL`, `DISTINCT` или пустая строка. Однако если вы используете `UNION` с настройкой `union_default_mode`, значением которой является пустая строка, то будет сгенерировано исключение. В следующих примерах продемонстрированы результаты запросов при разных значениях настройки. -# Секция UNION {#union-clause} +Запрос: -По умолчанию, `UNION` ведет себя так же, как и `UNION DISTINCT`. Но вы можете указать особый режим объединения с помощью настройки [union_default_mode](../../../operations/settings/settings.md#union-default-mode), значениями которой могут быть `ALL`, `DISTINCT` или пустая строка. Однако если вы используете `UNION` с настройкой `union_default_mode`, значением которой является пустая строка, то будет сгенерировано исключение. +```sql +SET union_default_mode = 'DISTINCT'; +SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; +``` -## Детали реализации {#implementation-details} +Результат: + +```text +┌─1─┐ +│ 1 │ +└───┘ +┌─1─┐ +│ 2 │ +└───┘ +┌─1─┐ +│ 3 │ +└───┘ +``` + +Запрос: + +```sql +SET union_default_mode = 'ALL'; +SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; +``` + +Результат: + +```text +┌─1─┐ +│ 1 │ +└───┘ +┌─1─┐ +│ 2 │ +└───┘ +┌─1─┐ +│ 2 │ +└───┘ +┌─1─┐ +│ 3 │ +└───┘ +``` Запросы, которые являются частью `UNION ALL`, выполняются параллельно, и их результаты могут быть смешаны вместе. -[Оригинальная статья](https://clickhouse.tech/docs/ru/sql-reference/statements/select/union-all/) +[Оригинальная статья](https://clickhouse.tech/docs/ru/sql-reference/statements/select/union/) diff --git a/docs/tr/sql-reference/statements/select/union-all.md b/docs/tr/sql-reference/statements/select/union-all.md deleted file mode 120000 index 837caae2698..00000000000 --- a/docs/tr/sql-reference/statements/select/union-all.md +++ /dev/null @@ -1 +0,0 @@ -../../../../en/sql-reference/statements/select/union-all.md \ No newline at end of file diff --git a/docs/tr/sql-reference/statements/select/union.md b/docs/tr/sql-reference/statements/select/union.md new file mode 100644 index 00000000000..0eb8db0be7a --- /dev/null +++ b/docs/tr/sql-reference/statements/select/union.md @@ -0,0 +1 @@ +../../../../en/sql-reference/statements/select/union.md \ No newline at end of file diff --git a/docs/zh/sql-reference/statements/select/index.md b/docs/zh/sql-reference/statements/select/index.md index cdfd64ff190..689a4f91a0c 100644 --- a/docs/zh/sql-reference/statements/select/index.md +++ b/docs/zh/sql-reference/statements/select/index.md @@ -46,7 +46,7 @@ SELECT [DISTINCT] expr_list - [SELECT 子句](#select-clause) - [DISTINCT 子句](../../../sql-reference/statements/select/distinct.md) - [LIMIT 子句](../../../sql-reference/statements/select/limit.md) -- [UNION ALL 子句](../../../sql-reference/statements/select/union-all.md) +- [UNION ALL 子句](../../../sql-reference/statements/select/union.md) - [INTO OUTFILE 子句](../../../sql-reference/statements/select/into-outfile.md) - [FORMAT 子句](../../../sql-reference/statements/select/format.md) diff --git a/docs/zh/sql-reference/statements/select/union-all.md b/docs/zh/sql-reference/statements/select/union.md similarity index 97% rename from docs/zh/sql-reference/statements/select/union-all.md rename to docs/zh/sql-reference/statements/select/union.md index d32ae896f55..1d88f9674c8 100644 --- a/docs/zh/sql-reference/statements/select/union-all.md +++ b/docs/zh/sql-reference/statements/select/union.md @@ -2,7 +2,7 @@ toc_title: UNION ALL --- -# UNION ALL子句 {#union-all-clause} +# UNION ALL子句 {#union-clause} 你可以使用 `UNION ALL` 结合任意数量的 `SELECT` 来扩展其结果。 示例: