mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge branch 'master' into send-logs-on-fatal-errors
This commit is contained in:
commit
b50b4b14de
@ -13,8 +13,3 @@ ClickHouse is an open-source column-oriented database management system that all
|
||||
* [Yandex.Messenger channel](https://yandex.ru/chat/#/join/20e380d9-c7be-4123-ab06-e95fb946975e) shares announcements and useful links in Russian.
|
||||
* [Contacts](https://clickhouse.tech/#contacts) can help to get your questions answered if there are any.
|
||||
* You can also [fill this form](https://clickhouse.tech/#meet) to meet Yandex ClickHouse team in person.
|
||||
|
||||
## Upcoming Events
|
||||
|
||||
* [ClickHouse Workshop in Novosibirsk](https://2020.codefest.ru/lecture/1628) on TBD date.
|
||||
* [Yandex C++ Open-Source Sprints in Moscow](https://events.yandex.ru/events/otkrytyj-kod-v-yandek-28-03-2020) on TBD date.
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include <Common/getMultipleKeysFromConfig.h>
|
||||
#include <Common/ClickHouseRevision.h>
|
||||
#include <Common/Config/ConfigProcessor.h>
|
||||
#include <Common/SymbolIndex.h>
|
||||
|
||||
#if !defined(ARCADIA_BUILD)
|
||||
# include <Common/config_version.h>
|
||||
@ -241,7 +242,8 @@ private:
|
||||
|
||||
void onTerminate(const std::string & message, UInt32 thread_num) const
|
||||
{
|
||||
LOG_FATAL(log, "(version {}{}) (from thread {}) {}", VERSION_STRING, VERSION_OFFICIAL, thread_num, message);
|
||||
LOG_FATAL(log, "(version {}{}, {}) (from thread {}) {}",
|
||||
VERSION_STRING, VERSION_OFFICIAL, daemon.build_id_info, thread_num, message);
|
||||
}
|
||||
|
||||
void onFault(
|
||||
@ -265,17 +267,15 @@ private:
|
||||
|
||||
LOG_FATAL(log, "########################################");
|
||||
|
||||
if (query_id.empty())
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "(version " << VERSION_STRING << VERSION_OFFICIAL << ")";
|
||||
message << " (from thread " << thread_num << ")";
|
||||
if (query_id.empty())
|
||||
message << " (no query)";
|
||||
else
|
||||
message << " (query_id: " << query_id << ")";
|
||||
message << " Received signal " << strsignal(sig) << " (" << sig << ").";
|
||||
|
||||
LOG_FATAL(log, message.str());
|
||||
LOG_FATAL(log, "(version {}{}, {}) (from thread {}) (no query) Received signal {} ({})",
|
||||
VERSION_STRING, VERSION_OFFICIAL, daemon.build_id_info, thread_num, strsignal(sig), sig);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_FATAL(log, "(version {}{}, {}) (from thread {}) (query_id: {}) Received signal {} ({})",
|
||||
VERSION_STRING, VERSION_OFFICIAL, daemon.build_id_info, thread_num, query_id, strsignal(sig), sig);
|
||||
}
|
||||
|
||||
LOG_FATAL(log, signalToErrorMessage(sig, info, context));
|
||||
@ -312,17 +312,15 @@ static void sanitizerDeathCallback()
|
||||
|
||||
StringRef query_id = DB::CurrentThread::getQueryId(); /// This is signal safe.
|
||||
|
||||
if (query_id.size == 0)
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "(version " << VERSION_STRING << VERSION_OFFICIAL << ")";
|
||||
message << " (from thread " << getThreadId() << ")";
|
||||
if (query_id.size == 0)
|
||||
message << " (no query)";
|
||||
else
|
||||
message << " (query_id: " << query_id << ")";
|
||||
message << " Sanitizer trap.";
|
||||
|
||||
LOG_FATAL(log, message.str());
|
||||
LOG_FATAL(log, "(version {}{}) (from thread {}) (no query) Sanitizer trap.",
|
||||
VERSION_STRING, VERSION_OFFICIAL, getThreadId());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_FATAL(log, "(version {}{}) (from thread {}) (query_id: {}) Sanitizer trap.",
|
||||
VERSION_STRING, VERSION_OFFICIAL, getThreadId(), query_id);
|
||||
}
|
||||
|
||||
/// Just in case print our own stack trace. In case when llvm-symbolizer does not work.
|
||||
@ -731,12 +729,23 @@ void BaseDaemon::initializeTerminationAndSignalProcessing()
|
||||
|
||||
signal_listener = std::make_unique<SignalListener>(*this);
|
||||
signal_listener_thread.start(*signal_listener);
|
||||
|
||||
#if defined(__ELF__) && !defined(__FreeBSD__)
|
||||
String build_id_hex = DB::SymbolIndex::instance().getBuildIDHex();
|
||||
if (build_id_hex.empty())
|
||||
build_id_info = "no build id";
|
||||
else
|
||||
build_id_info = "build id: " + build_id_hex;
|
||||
#else
|
||||
build_id_info = "no build id";
|
||||
#endif
|
||||
}
|
||||
|
||||
void BaseDaemon::logRevision() const
|
||||
{
|
||||
Poco::Logger::root().information("Starting " + std::string{VERSION_FULL}
|
||||
+ " with revision " + std::to_string(ClickHouseRevision::get())
|
||||
+ ", " + build_id_info
|
||||
+ ", PID " + std::to_string(getpid()));
|
||||
}
|
||||
|
||||
|
@ -198,6 +198,8 @@ protected:
|
||||
std::string config_path;
|
||||
DB::ConfigProcessor::LoadedConfig loaded_config;
|
||||
Poco::Util::AbstractConfiguration * last_configuration = nullptr;
|
||||
|
||||
String build_id_info;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
../../en/commercial/support.md
|
23
docs/zh/commercial/support.md
Normal file
23
docs/zh/commercial/support.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_priority: 3
|
||||
toc_title: "\u788C\u83BD\u7984Support:"
|
||||
---
|
||||
|
||||
# ClickHouse商业支持服务提供商 {#clickhouse-commercial-support-service-providers}
|
||||
|
||||
!!! info "信息"
|
||||
如果您已经推出ClickHouse商业支持服务,请随时 [打开拉取请求](https://github.com/ClickHouse/ClickHouse/edit/master/docs/en/commercial/support.md) 将其添加到以下列表。
|
||||
|
||||
## 敏锐性 {#altinity}
|
||||
|
||||
隆隆隆隆路虏脢..陇.貌.垄拢卢虏禄and陇.貌路.隆拢脳枚脢虏 隆隆隆隆路虏脢..陇.貌.垄拢卢虏禄.陇 访问 [www.altinity.com](https://www.altinity.com/) 欲了解更多信息.
|
||||
|
||||
## Mafiree {#mafiree}
|
||||
|
||||
[服务说明](http://mafiree.com/clickhouse-analytics-services.php)
|
||||
|
||||
## MinervaDB {#minervadb}
|
||||
|
||||
[服务说明](https://minervadb.com/index.php/clickhouse-consulting-and-support-by-minervadb/)
|
@ -33,7 +33,7 @@ ClickHouse 收集的指标项:
|
||||
- 服务用于计算的资源占用的各种指标。
|
||||
- 关于查询处理的常见统计信息。
|
||||
|
||||
可以在 [系统指标](system-tables.md#system_tables-metrics) ,[系统事件](system-tables.md#system_tables-events) 以及[系统异步指标](system-tables.md#system_tables-asynchronous_metrics) 等系统表查看所有的指标项。
|
||||
可以在 [系统指标](system-tables/metrics.md#system_tables-metrics) ,[系统事件](system-tables/events.md#system_tables-events) 以及[系统异步指标](system-tables/asynchronous_metrics.md#system_tables-asynchronous_metrics) 等系统表查看所有的指标项。
|
||||
|
||||
可以配置ClickHouse 往 [石墨](https://github.com/graphite-project)导入指标。 参考 [石墨部分](server-configuration-parameters/settings.md#server_configuration_parameters-graphite) 配置文件。在配置指标导出之前,需要参考Graphite[官方教程](https://graphite.readthedocs.io/en/latest/install.html)搭建服务。
|
||||
|
||||
|
@ -13,7 +13,7 @@ ClickHouse运行允许分析查询执行的采样探查器。 使用探查器,
|
||||
|
||||
- 设置 [trace\_log](../server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) 服务器配置部分。
|
||||
|
||||
本节配置 [trace\_log](../../operations/system-tables.md#system_tables-trace_log) 系统表包含探查器运行的结果。 它是默认配置的。 请记住,此表中的数据仅对正在运行的服务器有效。 服务器重新启动后,ClickHouse不会清理表,所有存储的虚拟内存地址都可能无效。
|
||||
本节配置 [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log) 系统表包含探查器运行的结果。 它是默认配置的。 请记住,此表中的数据仅对正在运行的服务器有效。 服务器重新启动后,ClickHouse不会清理表,所有存储的虚拟内存地址都可能无效。
|
||||
|
||||
- 设置 [query\_profiler\_cpu\_time\_period\_ns](../settings/settings.md#query_profiler_cpu_time_period_ns) 或 [query\_profiler\_real\_time\_period\_ns](../settings/settings.md#query_profiler_real_time_period_ns) 设置。 这两种设置可以同时使用。
|
||||
|
||||
|
@ -145,10 +145,10 @@ ClickHouse每x秒重新加载内置字典。 这使得编辑字典 “on the fly
|
||||
- interval – The interval for sending, in seconds.
|
||||
- timeout – The timeout for sending data, in seconds.
|
||||
- root\_path – Prefix for keys.
|
||||
- metrics – Sending data from the [系统。指标](../../operations/system-tables.md#system_tables-metrics) 桌子
|
||||
- events – Sending deltas data accumulated for the time period from the [系统。活动](../../operations/system-tables.md#system_tables-events) 桌子
|
||||
- events\_cumulative – Sending cumulative data from the [系统。活动](../../operations/system-tables.md#system_tables-events) 桌子
|
||||
- asynchronous\_metrics – Sending data from the [系统。asynchronous\_metrics](../../operations/system-tables.md#system_tables-asynchronous_metrics) 桌子
|
||||
- metrics – Sending data from the [系统。指标](../../operations/system-tables/metrics.md#system_tables-metrics) 桌子
|
||||
- events – Sending deltas data accumulated for the time period from the [系统。活动](../../operations/system-tables/events.md#system_tables-events) 桌子
|
||||
- events\_cumulative – Sending cumulative data from the [系统。活动](../../operations/system-tables/events.md#system_tables-events) 桌子
|
||||
- asynchronous\_metrics – Sending data from the [系统。asynchronous\_metrics](../../operations/system-tables/asynchronous_metrics.md#system_tables-asynchronous_metrics) 桌子
|
||||
|
||||
您可以配置多个 `<graphite>` 条款 例如,您可以使用它以不同的时间间隔发送不同的数据。
|
||||
|
||||
@ -503,7 +503,7 @@ SSL客户端/服务器配置。
|
||||
|
||||
记录与之关联的事件 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md). 例如,添加或合并数据。 您可以使用日志来模拟合并算法并比较它们的特征。 您可以可视化合并过程。
|
||||
|
||||
查询记录在 [系统。part\_log](../../operations/system-tables.md#system_tables-part-log) 表,而不是在一个单独的文件。 您可以在以下命令中配置此表的名称 `table` 参数(见下文)。
|
||||
查询记录在 [系统。part\_log](../../operations/system-tables/part_log.md#system_tables-part-log) 表,而不是在一个单独的文件。 您可以在以下命令中配置此表的名称 `table` 参数(见下文)。
|
||||
|
||||
使用以下参数配置日志记录:
|
||||
|
||||
@ -540,7 +540,7 @@ SSL客户端/服务器配置。
|
||||
|
||||
用于记录接收到的查询的设置 [log\_queries=1](../settings/settings.md) 设置。
|
||||
|
||||
查询记录在 [系统。query\_log](../../operations/system-tables.md#system_tables-query_log) 表,而不是在一个单独的文件。 您可以更改表的名称 `table` 参数(见下文)。
|
||||
查询记录在 [系统。query\_log](../../operations/system-tables/query_log.md#system_tables-query_log) 表,而不是在一个单独的文件。 您可以更改表的名称 `table` 参数(见下文)。
|
||||
|
||||
使用以下参数配置日志记录:
|
||||
|
||||
@ -566,7 +566,7 @@ SSL客户端/服务器配置。
|
||||
|
||||
设置用于记录接收到的查询的线程 [log\_query\_threads=1](../settings/settings.md#settings-log-query-threads) 设置。
|
||||
|
||||
查询记录在 [系统。query\_thread\_log](../../operations/system-tables.md#system_tables-query-thread-log) 表,而不是在一个单独的文件。 您可以更改表的名称 `table` 参数(见下文)。
|
||||
查询记录在 [系统。query\_thread\_log](../../operations/system-tables/query_thread_log.md#system_tables-query-thread-log) 表,而不是在一个单独的文件。 您可以更改表的名称 `table` 参数(见下文)。
|
||||
|
||||
使用以下参数配置日志记录:
|
||||
|
||||
@ -590,7 +590,7 @@ SSL客户端/服务器配置。
|
||||
|
||||
## trace\_log {#server_configuration_parameters-trace_log}
|
||||
|
||||
设置为 [trace\_log](../../operations/system-tables.md#system_tables-trace_log) 系统表操作。
|
||||
设置为 [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log) 系统表操作。
|
||||
|
||||
参数:
|
||||
|
||||
|
@ -1165,7 +1165,7 @@ ClickHouse生成异常
|
||||
|
||||
另请参阅:
|
||||
|
||||
- 系统表 [trace\_log](../../operations/system-tables.md#system_tables-trace_log)
|
||||
- 系统表 [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log)
|
||||
|
||||
## query\_profiler\_cpu\_time\_period\_ns {#query_profiler_cpu_time_period_ns}
|
||||
|
||||
@ -1188,7 +1188,7 @@ ClickHouse生成异常
|
||||
|
||||
另请参阅:
|
||||
|
||||
- 系统表 [trace\_log](../../operations/system-tables.md#system_tables-trace_log)
|
||||
- 系统表 [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log)
|
||||
|
||||
## allow\_introspection\_functions {#settings-allow_introspection_functions}
|
||||
|
||||
@ -1204,7 +1204,7 @@ ClickHouse生成异常
|
||||
**另请参阅**
|
||||
|
||||
- [采样查询探查器](../optimizing-performance/sampling-query-profiler.md)
|
||||
- 系统表 [trace\_log](../../operations/system-tables.md#system_tables-trace_log)
|
||||
- 系统表 [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log)
|
||||
|
||||
## input\_format\_parallel\_parsing {#input-format-parallel-parsing}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
## 系统。asynchronous\_metric\_log {#system-tables-async-log}
|
||||
|
||||
包含以下内容的历史值 `system.asynchronous_log` (见 [系统。asynchronous\_metrics](../../operations/system-tables/asynchronous_metrics.md#system_tables-asynchronous_metrics))
|
41
docs/zh/operations/system-tables/asynchronous_metrics.md
Normal file
41
docs/zh/operations/system-tables/asynchronous_metrics.md
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。asynchronous\_metrics {#system_tables-asynchronous_metrics}
|
||||
|
||||
包含在后台定期计算的指标。 例如,在使用的RAM量。
|
||||
|
||||
列:
|
||||
|
||||
- `metric` ([字符串](../../sql-reference/data-types/string.md)) — Metric name.
|
||||
- `value` ([Float64](../../sql-reference/data-types/float.md)) — Metric value.
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.asynchronous_metrics LIMIT 10
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─metric──────────────────────────────────┬──────value─┐
|
||||
│ jemalloc.background_thread.run_interval │ 0 │
|
||||
│ jemalloc.background_thread.num_runs │ 0 │
|
||||
│ jemalloc.background_thread.num_threads │ 0 │
|
||||
│ jemalloc.retained │ 422551552 │
|
||||
│ jemalloc.mapped │ 1682989056 │
|
||||
│ jemalloc.resident │ 1656446976 │
|
||||
│ jemalloc.metadata_thp │ 0 │
|
||||
│ jemalloc.metadata │ 10226856 │
|
||||
│ UncompressedCacheCells │ 0 │
|
||||
│ MarkCacheFiles │ 0 │
|
||||
└─────────────────────────────────────────┴────────────┘
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [监测](../../operations/monitoring.md) — Base concepts of ClickHouse monitoring.
|
||||
- [系统。指标](../../operations/system-tables/metrics.md#system_tables-metrics) — Contains instantly calculated metrics.
|
||||
- [系统。活动](../../operations/system-tables/events.md#system_tables-events) — Contains a number of events that have occurred.
|
||||
- [系统。metric\_log](../../operations/system-tables/metric_log.md#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`.
|
29
docs/zh/operations/system-tables/clusters.md
Normal file
29
docs/zh/operations/system-tables/clusters.md
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。集群 {#system-clusters}
|
||||
|
||||
包含有关配置文件中可用的集群及其中的服务器的信息。
|
||||
|
||||
列:
|
||||
|
||||
- `cluster` (String) — The cluster name.
|
||||
- `shard_num` (UInt32) — The shard number in the cluster, starting from 1.
|
||||
- `shard_weight` (UInt32) — The relative weight of the shard when writing data.
|
||||
- `replica_num` (UInt32) — The replica number in the shard, starting from 1.
|
||||
- `host_name` (String) — The host name, as specified in the config.
|
||||
- `host_address` (String) — The host IP address obtained from DNS.
|
||||
- `port` (UInt16) — The port to use for connecting to the server.
|
||||
- `user` (String) — The name of the user for connecting to the server.
|
||||
- `errors_count` (UInt32)-此主机无法到达副本的次数。
|
||||
- `estimated_recovery_time` (UInt32)-剩下的秒数,直到副本错误计数归零,它被认为是恢复正常。
|
||||
|
||||
请注意 `errors_count` 每个查询集群更新一次,但 `estimated_recovery_time` 按需重新计算。 所以有可能是非零的情况 `errors_count` 和零 `estimated_recovery_time`,下一个查询将为零 `errors_count` 并尝试使用副本,就好像它没有错误。
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [表引擎分布式](../../engines/table-engines/special/distributed.md)
|
||||
- [distributed\_replica\_error\_cap设置](../../operations/settings/settings.md#settings-distributed_replica_error_cap)
|
||||
- [distributed\_replica\_error\_half\_life设置](../../operations/settings/settings.md#settings-distributed_replica_error_half_life)
|
27
docs/zh/operations/system-tables/columns.md
Normal file
27
docs/zh/operations/system-tables/columns.md
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。列 {#system-columns}
|
||||
|
||||
包含有关所有表中列的信息。
|
||||
|
||||
您可以使用此表获取类似于以下内容的信息 [DESCRIBE TABLE](../../sql-reference/statements/misc.md#misc-describe-table) 查询,但对于多个表一次。
|
||||
|
||||
该 `system.columns` 表包含以下列(列类型显示在括号中):
|
||||
|
||||
- `database` (String) — Database name.
|
||||
- `table` (String) — Table name.
|
||||
- `name` (String) — Column name.
|
||||
- `type` (String) — Column type.
|
||||
- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`)为默认值,如果没有定义,则为空字符串。
|
||||
- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined.
|
||||
- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes.
|
||||
- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes.
|
||||
- `marks_bytes` (UInt64) — The size of marks, in bytes.
|
||||
- `comment` (String) — Comment on the column, or an empty string if it is not defined.
|
||||
- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression.
|
||||
- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression.
|
||||
- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression.
|
||||
- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression.
|
45
docs/zh/operations/system-tables/contributors.md
Normal file
45
docs/zh/operations/system-tables/contributors.md
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。贡献者 {#system-contributors}
|
||||
|
||||
包含有关贡献者的信息。 该顺序在查询执行时是随机的。
|
||||
|
||||
列:
|
||||
|
||||
- `name` (String) — Contributor (author) name from git log.
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.contributors LIMIT 10
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─name─────────────┐
|
||||
│ Olga Khvostikova │
|
||||
│ Max Vetrov │
|
||||
│ LiuYangkuan │
|
||||
│ svladykin │
|
||||
│ zamulla │
|
||||
│ Šimon Podlipský │
|
||||
│ BayoNet │
|
||||
│ Ilya Khomutov │
|
||||
│ Amy Krishnevsky │
|
||||
│ Loud_Scream │
|
||||
└──────────────────┘
|
||||
```
|
||||
|
||||
要在表中找出自己,请使用查询:
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.contributors WHERE name = 'Olga Khvostikova'
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─name─────────────┐
|
||||
│ Olga Khvostikova │
|
||||
└──────────────────┘
|
||||
```
|
39
docs/zh/operations/system-tables/data_type_families.md
Normal file
39
docs/zh/operations/system-tables/data_type_families.md
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。data\_type\_families {#system_tables-data_type_families}
|
||||
|
||||
包含有关受支持的信息 [数据类型](../../sql-reference/data-types/).
|
||||
|
||||
列:
|
||||
|
||||
- `name` ([字符串](../../sql-reference/data-types/string.md)) — Data type name.
|
||||
- `case_insensitive` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Property that shows whether you can use a data type name in a query in case insensitive manner or not. For example, `Date` 和 `date` 都是有效的。
|
||||
- `alias_to` ([字符串](../../sql-reference/data-types/string.md)) — Data type name for which `name` 是个化名
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.data_type_families WHERE alias_to = 'String'
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─name───────┬─case_insensitive─┬─alias_to─┐
|
||||
│ LONGBLOB │ 1 │ String │
|
||||
│ LONGTEXT │ 1 │ String │
|
||||
│ TINYTEXT │ 1 │ String │
|
||||
│ TEXT │ 1 │ String │
|
||||
│ VARCHAR │ 1 │ String │
|
||||
│ MEDIUMBLOB │ 1 │ String │
|
||||
│ BLOB │ 1 │ String │
|
||||
│ TINYBLOB │ 1 │ String │
|
||||
│ CHAR │ 1 │ String │
|
||||
│ MEDIUMTEXT │ 1 │ String │
|
||||
└────────────┴──────────────────┴──────────┘
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [语法](../../sql-reference/syntax.md) — Information about supported syntax.
|
12
docs/zh/operations/system-tables/databases.md
Normal file
12
docs/zh/operations/system-tables/databases.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。数据库 {#system-databases}
|
||||
|
||||
此表包含一个名为"字符串"的列 ‘name’ – the name of a database.
|
||||
|
||||
服务器知道的每个数据库在表中都有相应的条目。
|
||||
|
||||
该系统表用于实现 `SHOW DATABASES` 查询。
|
14
docs/zh/operations/system-tables/detached_parts.md
Normal file
14
docs/zh/operations/system-tables/detached_parts.md
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。detached\_parts {#system_tables-detached_parts}
|
||||
|
||||
包含有关分离部分的信息 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 桌子 该 `reason` 列指定分离部件的原因。
|
||||
|
||||
对于用户分离的部件,原因是空的。 这些部件可以附加 [ALTER TABLE ATTACH PARTITION\|PART](../../sql-reference/statements/alter.md#alter_attach-partition) 指挥部
|
||||
|
||||
有关其他列的说明,请参阅 [系统。零件](../../operations/system-tables/parts.md#system_tables-parts).
|
||||
|
||||
如果部件名称无效,某些列的值可能为 `NULL`. 这些部分可以删除 [ALTER TABLE DROP DETACHED PART](../../sql-reference/statements/alter.md#alter_drop-detached).
|
66
docs/zh/operations/system-tables/dictionaries.md
Normal file
66
docs/zh/operations/system-tables/dictionaries.md
Normal file
@ -0,0 +1,66 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。字典 {#system_tables-dictionaries}
|
||||
|
||||
包含以下信息 [外部字典](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md).
|
||||
|
||||
列:
|
||||
|
||||
- `database` ([字符串](../../sql-reference/data-types/string.md)) — Name of the database containing the dictionary created by DDL query. Empty string for other dictionaries.
|
||||
- `name` ([字符串](../../sql-reference/data-types/string.md)) — [字典名称](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict.md).
|
||||
- `status` ([枚举8](../../sql-reference/data-types/enum.md)) — Dictionary status. Possible values:
|
||||
- `NOT_LOADED` — Dictionary was not loaded because it was not used.
|
||||
- `LOADED` — Dictionary loaded successfully.
|
||||
- `FAILED` — Unable to load the dictionary as a result of an error.
|
||||
- `LOADING` — Dictionary is loading now.
|
||||
- `LOADED_AND_RELOADING` — Dictionary is loaded successfully, and is being reloaded right now (frequent reasons: [SYSTEM RELOAD DICTIONARY](../../sql-reference/statements/system.md#query_language-system-reload-dictionary) 查询,超时,字典配置已更改)。
|
||||
- `FAILED_AND_RELOADING` — Could not load the dictionary as a result of an error and is loading now.
|
||||
- `origin` ([字符串](../../sql-reference/data-types/string.md)) — Path to the configuration file that describes the dictionary.
|
||||
- `type` ([字符串](../../sql-reference/data-types/string.md)) — Type of a dictionary allocation. [在内存中存储字典](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md).
|
||||
- `key` — [密钥类型](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-key):数字键 ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) or Сomposite key ([字符串](../../sql-reference/data-types/string.md)) — form “(type 1, type 2, …, type n)”.
|
||||
- `attribute.names` ([阵列](../../sql-reference/data-types/array.md)([字符串](../../sql-reference/data-types/string.md))) — Array of [属性名称](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) 由字典提供。
|
||||
- `attribute.types` ([阵列](../../sql-reference/data-types/array.md)([字符串](../../sql-reference/data-types/string.md))) — Corresponding array of [属性类型](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md#ext_dict_structure-attributes) 这是由字典提供。
|
||||
- `bytes_allocated` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Amount of RAM allocated for the dictionary.
|
||||
- `query_count` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of queries since the dictionary was loaded or since the last successful reboot.
|
||||
- `hit_rate` ([Float64](../../sql-reference/data-types/float.md)) — For cache dictionaries, the percentage of uses for which the value was in the cache.
|
||||
- `element_count` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of items stored in the dictionary.
|
||||
- `load_factor` ([Float64](../../sql-reference/data-types/float.md)) — Percentage filled in the dictionary (for a hashed dictionary, the percentage filled in the hash table).
|
||||
- `source` ([字符串](../../sql-reference/data-types/string.md)) — Text describing the [数据源](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources.md) 为了字典
|
||||
- `lifetime_min` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Minimum [使用寿命](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) 在内存中的字典,之后ClickHouse尝试重新加载字典(如果 `invalidate_query` 被设置,那么只有当它已经改变)。 在几秒钟内设置。
|
||||
- `lifetime_max` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Maximum [使用寿命](../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-lifetime.md) 在内存中的字典,之后ClickHouse尝试重新加载字典(如果 `invalidate_query` 被设置,那么只有当它已经改变)。 在几秒钟内设置。
|
||||
- `loading_start_time` ([日期时间](../../sql-reference/data-types/datetime.md)) — Start time for loading the dictionary.
|
||||
- `last_successful_update_time` ([日期时间](../../sql-reference/data-types/datetime.md)) — End time for loading or updating the dictionary. Helps to monitor some troubles with external sources and investigate causes.
|
||||
- `loading_duration` ([Float32](../../sql-reference/data-types/float.md)) — Duration of a dictionary loading.
|
||||
- `last_exception` ([字符串](../../sql-reference/data-types/string.md)) — Text of the error that occurs when creating or reloading the dictionary if the dictionary couldn't be created.
|
||||
|
||||
**示例**
|
||||
|
||||
配置字典。
|
||||
|
||||
``` sql
|
||||
CREATE DICTIONARY dictdb.dict
|
||||
(
|
||||
`key` Int64 DEFAULT -1,
|
||||
`value_default` String DEFAULT 'world',
|
||||
`value_expression` String DEFAULT 'xxx' EXPRESSION 'toString(127 * 172)'
|
||||
)
|
||||
PRIMARY KEY key
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'dicttbl' DB 'dictdb'))
|
||||
LIFETIME(MIN 0 MAX 1)
|
||||
LAYOUT(FLAT())
|
||||
```
|
||||
|
||||
确保字典已加载。
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.dictionaries
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─database─┬─name─┬─status─┬─origin──────┬─type─┬─key────┬─attribute.names──────────────────────┬─attribute.types─────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬───────────load_factor─┬─source─────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┌──last_successful_update_time─┬──────loading_duration─┬─last_exception─┐
|
||||
│ dictdb │ dict │ LOADED │ dictdb.dict │ Flat │ UInt64 │ ['value_default','value_expression'] │ ['String','String'] │ 74032 │ 0 │ 1 │ 1 │ 0.0004887585532746823 │ ClickHouse: dictdb.dicttbl │ 0 │ 1 │ 2020-03-04 04:17:34 │ 2020-03-04 04:30:34 │ 0.002 │ │
|
||||
└──────────┴──────┴────────┴─────────────┴──────┴────────┴──────────────────────────────────────┴─────────────────────┴─────────────────┴─────────────┴──────────┴───────────────┴───────────────────────┴────────────────────────────┴──────────────┴──────────────┴─────────────────────┴──────────────────────────────┘───────────────────────┴────────────────┘
|
||||
```
|
31
docs/zh/operations/system-tables/disks.md
Normal file
31
docs/zh/operations/system-tables/disks.md
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。磁盘 {#system_tables-disks}
|
||||
|
||||
包含有关在定义的磁盘信息 [服务器配置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure).
|
||||
|
||||
列:
|
||||
|
||||
- `name` ([字符串](../../sql-reference/data-types/string.md)) — Name of a disk in the server configuration.
|
||||
- `path` ([字符串](../../sql-reference/data-types/string.md)) — Path to the mount point in the file system.
|
||||
- `free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Free space on disk in bytes.
|
||||
- `total_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Disk volume in bytes.
|
||||
- `keep_free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` 磁盘配置参数。
|
||||
|
||||
## 系统。storage\_policies {#system_tables-storage_policies}
|
||||
|
||||
包含有关存储策略和卷中定义的信息 [服务器配置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure).
|
||||
|
||||
列:
|
||||
|
||||
- `policy_name` ([字符串](../../sql-reference/data-types/string.md)) — Name of the storage policy.
|
||||
- `volume_name` ([字符串](../../sql-reference/data-types/string.md)) — Volume name defined in the storage policy.
|
||||
- `volume_priority` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Volume order number in the configuration.
|
||||
- `disks` ([数组(字符串)](../../sql-reference/data-types/array.md)) — Disk names, defined in the storage policy.
|
||||
- `max_data_part_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit).
|
||||
- `move_factor` ([Float64](../../sql-reference/data-types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order.
|
||||
|
||||
如果存储策略包含多个卷,则每个卷的信息将存储在表的单独行中。
|
37
docs/zh/operations/system-tables/events.md
Normal file
37
docs/zh/operations/system-tables/events.md
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。活动 {#system_tables-events}
|
||||
|
||||
包含有关系统中发生的事件数的信息。 例如,在表中,您可以找到多少 `SELECT` 自ClickHouse服务器启动以来已处理查询。
|
||||
|
||||
列:
|
||||
|
||||
- `event` ([字符串](../../sql-reference/data-types/string.md)) — Event name.
|
||||
- `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Number of events occurred.
|
||||
- `description` ([字符串](../../sql-reference/data-types/string.md)) — Event description.
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.events LIMIT 5
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─event─────────────────────────────────┬─value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Query │ 12 │ Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries. │
|
||||
│ SelectQuery │ 8 │ Same as Query, but only for SELECT queries. │
|
||||
│ FileOpen │ 73 │ Number of files opened. │
|
||||
│ ReadBufferFromFileDescriptorRead │ 155 │ Number of reads (read/pread) from a file descriptor. Does not include sockets. │
|
||||
│ ReadBufferFromFileDescriptorReadBytes │ 9931 │ Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size. │
|
||||
└───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [系统。asynchronous\_metrics](../../operations/system-tables/asynchronous_metrics.md#system_tables-asynchronous_metrics) — Contains periodically calculated metrics.
|
||||
- [系统。指标](../../operations/system-tables/metrics.md#system_tables-metrics) — Contains instantly calculated metrics.
|
||||
- [系统。metric\_log](../../operations/system-tables/metric_log.md#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`.
|
||||
- [监测](../../operations/monitoring.md) — Base concepts of ClickHouse monitoring.
|
13
docs/zh/operations/system-tables/functions.md
Normal file
13
docs/zh/operations/system-tables/functions.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。功能 {#system-functions}
|
||||
|
||||
包含有关正常函数和聚合函数的信息。
|
||||
|
||||
列:
|
||||
|
||||
- `name`(`String`) – The name of the function.
|
||||
- `is_aggregate`(`UInt8`) — Whether the function is aggregate.
|
20
docs/zh/operations/system-tables/graphite_retentions.md
Normal file
20
docs/zh/operations/system-tables/graphite_retentions.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。graphite\_retentions {#system-graphite-retentions}
|
||||
|
||||
包含有关参数的信息 [graphite\_rollup](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-graphite) 这是在表中使用 [\*GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md) 引擎
|
||||
|
||||
列:
|
||||
|
||||
- `config_name` (字符串) - `graphite_rollup` 参数名称。
|
||||
- `regexp` (String)-指标名称的模式。
|
||||
- `function` (String)-聚合函数的名称。
|
||||
- `age` (UInt64)-以秒为单位的数据的最小期限。
|
||||
- `precision` (UInt64)-如何精确地定义以秒为单位的数据的年龄。
|
||||
- `priority` (UInt16)-模式优先级。
|
||||
- `is_default` (UInt8)-模式是否为默认值。
|
||||
- `Tables.database` (Array(String))-使用数据库表名称的数组 `config_name` 参数。
|
||||
- `Tables.table` (Array(String))-使用表名称的数组 `config_name` 参数。
|
50
docs/zh/operations/system-tables/index.md
Normal file
50
docs/zh/operations/system-tables/index.md
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_priority: 52
|
||||
toc_title: "\u7CFB\u7EDF\u8868"
|
||||
---
|
||||
|
||||
# 系统表 {#system-tables}
|
||||
|
||||
## 导言 {#system-tables-introduction}
|
||||
|
||||
系统表提供以下信息:
|
||||
|
||||
- 服务器状态、进程和环境。
|
||||
- 服务器的内部进程。
|
||||
|
||||
系统表:
|
||||
|
||||
- 坐落于 `system` 数据库。
|
||||
- 仅适用于读取数据。
|
||||
- 不能删除或更改,但可以分离。
|
||||
|
||||
大多数系统表将数据存储在RAM中。 ClickHouse服务器在开始时创建此类系统表。
|
||||
|
||||
与其他系统表不同,系统表 [metric\_log](../../operations/system-tables/metric_log.md#system_tables-metric_log), [query\_log](../../operations/system-tables/query_log.md#system_tables-query_log), [query\_thread\_log](../../operations/system-tables/query_thread_log.md#system_tables-query_thread_log), [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log) 由 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表引擎并将其数据存储在存储文件系统中。 如果从文件系统中删除表,ClickHouse服务器会在下一次写入数据时再次创建空表。 如果系统表架构在新版本中发生更改,则ClickHouse会重命名当前表并创建一个新表。
|
||||
|
||||
默认情况下,表增长是无限的。 要控制表的大小,可以使用 [TTL](../../sql-reference/statements/alter.md#manipulations-with-table-ttl) 删除过期日志记录的设置。 你也可以使用分区功能 `MergeTree`-发动机表。
|
||||
|
||||
## 系统指标的来源 {#system-tables-sources-of-system-metrics}
|
||||
|
||||
用于收集ClickHouse服务器使用的系统指标:
|
||||
|
||||
- `CAP_NET_ADMIN` 能力。
|
||||
- [procfs](https://en.wikipedia.org/wiki/Procfs) (仅在Linux中)。
|
||||
|
||||
**procfs**
|
||||
|
||||
如果ClickHouse服务器没有 `CAP_NET_ADMIN` 能力,它试图回落到 `ProcfsMetricsProvider`. `ProcfsMetricsProvider` 允许收集每个查询系统指标(用于CPU和I/O)。
|
||||
|
||||
如果系统上支持并启用procfs,ClickHouse server将收集这些指标:
|
||||
|
||||
- `OSCPUVirtualTimeMicroseconds`
|
||||
- `OSCPUWaitMicroseconds`
|
||||
- `OSIOWaitMicroseconds`
|
||||
- `OSReadChars`
|
||||
- `OSWriteChars`
|
||||
- `OSReadBytes`
|
||||
- `OSWriteBytes`
|
||||
|
||||
[原始文章](https://clickhouse.tech/docs/en/operations/system-tables/) <!--hide-->
|
16
docs/zh/operations/system-tables/merge_tree_settings.md
Normal file
16
docs/zh/operations/system-tables/merge_tree_settings.md
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。merge\_tree\_settings {#system-merge_tree_settings}
|
||||
|
||||
包含有关以下设置的信息 `MergeTree` 桌子
|
||||
|
||||
列:
|
||||
|
||||
- `name` (String) — Setting name.
|
||||
- `value` (String) — Setting value.
|
||||
- `description` (String) — Setting description.
|
||||
- `type` (String) — Setting type (implementation specific string value).
|
||||
- `changed` (UInt8) — Whether the setting was explicitly defined in the config or explicitly changed.
|
24
docs/zh/operations/system-tables/merges.md
Normal file
24
docs/zh/operations/system-tables/merges.md
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。合并 {#system-merges}
|
||||
|
||||
包含有关MergeTree系列中表当前正在进行的合并和部件突变的信息。
|
||||
|
||||
列:
|
||||
|
||||
- `database` (String) — The name of the database the table is in.
|
||||
- `table` (String) — Table name.
|
||||
- `elapsed` (Float64) — The time elapsed (in seconds) since the merge started.
|
||||
- `progress` (Float64) — The percentage of completed work from 0 to 1.
|
||||
- `num_parts` (UInt64) — The number of pieces to be merged.
|
||||
- `result_part_name` (String) — The name of the part that will be formed as the result of merging.
|
||||
- `is_mutation` (UInt8)-1如果这个过程是一个部分突变.
|
||||
- `total_size_bytes_compressed` (UInt64) — The total size of the compressed data in the merged chunks.
|
||||
- `total_size_marks` (UInt64) — The total number of marks in the merged parts.
|
||||
- `bytes_read_uncompressed` (UInt64) — Number of bytes read, uncompressed.
|
||||
- `rows_read` (UInt64) — Number of rows read.
|
||||
- `bytes_written_uncompressed` (UInt64) — Number of bytes written, uncompressed.
|
||||
- `rows_written` (UInt64) — Number of rows written.
|
60
docs/zh/operations/system-tables/metric_log.md
Normal file
60
docs/zh/operations/system-tables/metric_log.md
Normal file
@ -0,0 +1,60 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。metric\_log {#system_tables-metric_log}
|
||||
|
||||
包含表中度量值的历史记录 `system.metrics` 和 `system.events`,定期刷新到磁盘。
|
||||
打开指标历史记录收集 `system.metric_log`,创建 `/etc/clickhouse-server/config.d/metric_log.xml` 具有以下内容:
|
||||
|
||||
``` xml
|
||||
<yandex>
|
||||
<metric_log>
|
||||
<database>system</database>
|
||||
<table>metric_log</table>
|
||||
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
|
||||
<collect_interval_milliseconds>1000</collect_interval_milliseconds>
|
||||
</metric_log>
|
||||
</yandex>
|
||||
```
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical;
|
||||
```
|
||||
|
||||
``` text
|
||||
Row 1:
|
||||
──────
|
||||
event_date: 2020-02-18
|
||||
event_time: 2020-02-18 07:15:33
|
||||
milliseconds: 554
|
||||
ProfileEvent_Query: 0
|
||||
ProfileEvent_SelectQuery: 0
|
||||
ProfileEvent_InsertQuery: 0
|
||||
ProfileEvent_FileOpen: 0
|
||||
ProfileEvent_Seek: 0
|
||||
ProfileEvent_ReadBufferFromFileDescriptorRead: 1
|
||||
ProfileEvent_ReadBufferFromFileDescriptorReadFailed: 0
|
||||
ProfileEvent_ReadBufferFromFileDescriptorReadBytes: 0
|
||||
ProfileEvent_WriteBufferFromFileDescriptorWrite: 1
|
||||
ProfileEvent_WriteBufferFromFileDescriptorWriteFailed: 0
|
||||
ProfileEvent_WriteBufferFromFileDescriptorWriteBytes: 56
|
||||
...
|
||||
CurrentMetric_Query: 0
|
||||
CurrentMetric_Merge: 0
|
||||
CurrentMetric_PartMutation: 0
|
||||
CurrentMetric_ReplicatedFetch: 0
|
||||
CurrentMetric_ReplicatedSend: 0
|
||||
CurrentMetric_ReplicatedChecks: 0
|
||||
...
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [系统。asynchronous\_metrics](../../operations/system-tables/asynchronous_metrics.md#system_tables-asynchronous_metrics) — Contains periodically calculated metrics.
|
||||
- [系统。活动](../../operations/system-tables/events.md#system_tables-events) — Contains a number of events that occurred.
|
||||
- [系统。指标](../../operations/system-tables/metrics.md#system_tables-metrics) — Contains instantly calculated metrics.
|
||||
- [监测](../../operations/monitoring.md) — Base concepts of ClickHouse monitoring.
|
44
docs/zh/operations/system-tables/metrics.md
Normal file
44
docs/zh/operations/system-tables/metrics.md
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。指标 {#system_tables-metrics}
|
||||
|
||||
包含可以立即计算或具有当前值的指标。 例如,同时处理的查询的数量或当前副本的延迟。 此表始终是最新的。
|
||||
|
||||
列:
|
||||
|
||||
- `metric` ([字符串](../../sql-reference/data-types/string.md)) — Metric name.
|
||||
- `value` ([Int64](../../sql-reference/data-types/int-uint.md)) — Metric value.
|
||||
- `description` ([字符串](../../sql-reference/data-types/string.md)) — Metric description.
|
||||
|
||||
支持的指标列表,您可以在 [src/Common/CurrentMetrics.cpp](https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CurrentMetrics.cpp) ClickHouse的源文件。
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.metrics LIMIT 10
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─metric─────────────────────┬─value─┬─description──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Query │ 1 │ Number of executing queries │
|
||||
│ Merge │ 0 │ Number of executing background merges │
|
||||
│ PartMutation │ 0 │ Number of mutations (ALTER DELETE/UPDATE) │
|
||||
│ ReplicatedFetch │ 0 │ Number of data parts being fetched from replicas │
|
||||
│ ReplicatedSend │ 0 │ Number of data parts being sent to replicas │
|
||||
│ ReplicatedChecks │ 0 │ Number of data parts checking for consistency │
|
||||
│ BackgroundPoolTask │ 0 │ Number of active tasks in BackgroundProcessingPool (merges, mutations, fetches, or replication queue bookkeeping) │
|
||||
│ BackgroundSchedulePoolTask │ 0 │ Number of active tasks in BackgroundSchedulePool. This pool is used for periodic ReplicatedMergeTree tasks, like cleaning old data parts, altering data parts, replica re-initialization, etc. │
|
||||
│ DiskSpaceReservedForMerge │ 0 │ Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts. │
|
||||
│ DistributedSend │ 0 │ Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode. │
|
||||
└────────────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [系统。asynchronous\_metrics](../../operations/system-tables/asynchronous_metrics.md#system_tables-asynchronous_metrics) — Contains periodically calculated metrics.
|
||||
- [系统。活动](../../operations/system-tables/events.md#system_tables-events) — Contains a number of events that occurred.
|
||||
- [系统。metric\_log](../../operations/system-tables/metric_log.md#system_tables-metric_log) — Contains a history of metrics values from tables `system.metrics` и `system.events`.
|
||||
- [监测](../../operations/monitoring.md) — Base concepts of ClickHouse monitoring.
|
30
docs/zh/operations/system-tables/mutations.md
Normal file
30
docs/zh/operations/system-tables/mutations.md
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。突变 {#system_tables-mutations}
|
||||
|
||||
该表包含以下信息 [突变](../../sql-reference/statements/alter.md#alter-mutations) MergeTree表及其进展。 每个突变命令由一行表示。 该表具有以下列:
|
||||
|
||||
**数据库**, **表** -应用突变的数据库和表的名称。
|
||||
|
||||
**mutation\_id** -变异的ID 对于复制的表,这些Id对应于znode中的名称 `<table_path_in_zookeeper>/mutations/` 动物园管理员的目录。 对于未复制的表,Id对应于表的数据目录中的文件名。
|
||||
|
||||
**命令** -Mutation命令字符串(查询后的部分 `ALTER TABLE [db.]table`).
|
||||
|
||||
**create\_time** -当这个突变命令被提交执行。
|
||||
|
||||
**block\_numbers.partition\_id**, **block\_numbers.编号** -嵌套列。 对于复制表的突变,它包含每个分区的一条记录:分区ID和通过突变获取的块编号(在每个分区中,只有包含编号小于该分区中突变获取的块编号的块的 在非复制表中,所有分区中的块编号形成一个序列。 这意味着对于非复制表的突变,该列将包含一条记录,其中包含由突变获取的单个块编号。
|
||||
|
||||
**parts\_to\_do** -为了完成突变,需要突变的数据部分的数量。
|
||||
|
||||
**is\_done** -变异完成了?? 请注意,即使 `parts_to_do = 0` 由于长时间运行的INSERT将创建需要突变的新数据部分,因此可能尚未完成复制表的突变。
|
||||
|
||||
如果在改变某些部分时出现问题,以下列将包含其他信息:
|
||||
|
||||
**latest\_failed\_part** -不能变异的最新部分的名称。
|
||||
|
||||
**latest\_fail\_time** -最近的部分突变失败的时间。
|
||||
|
||||
**latest\_fail\_reason** -导致最近部件变异失败的异常消息。
|
12
docs/zh/operations/system-tables/numbers.md
Normal file
12
docs/zh/operations/system-tables/numbers.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。数字 {#system-numbers}
|
||||
|
||||
此表包含一个名为UInt64的列 `number` 它包含几乎所有从零开始的自然数。
|
||||
|
||||
您可以使用此表进行测试,或者如果您需要进行暴力搜索。
|
||||
|
||||
从此表中读取的内容不是并行的。
|
10
docs/zh/operations/system-tables/numbers_mt.md
Normal file
10
docs/zh/operations/system-tables/numbers_mt.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。numbers\_mt {#system-numbers-mt}
|
||||
|
||||
一样的 [系统。数字](../../operations/system-tables/numbers.md) 但读取是并行的。 这些数字可以以任何顺序返回。
|
||||
|
||||
用于测试。
|
12
docs/zh/operations/system-tables/one.md
Normal file
12
docs/zh/operations/system-tables/one.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。一 {#system-one}
|
||||
|
||||
此表包含一行,其中包含一行 `dummy` UInt8列包含值0。
|
||||
|
||||
如果使用此表 `SELECT` 查询不指定 `FROM` 条款
|
||||
|
||||
这类似于 `DUAL` 表在其他Dbms中找到。
|
37
docs/zh/operations/system-tables/part_log.md
Normal file
37
docs/zh/operations/system-tables/part_log.md
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。part\_log {#system_tables-part-log}
|
||||
|
||||
该 `system.part_log` 表只有当创建 [part\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-part-log) 指定了服务器设置。
|
||||
|
||||
此表包含与以下情况发生的事件有关的信息 [数据部分](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 在 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 家庭表,例如添加或合并数据。
|
||||
|
||||
该 `system.part_log` 表包含以下列:
|
||||
|
||||
- `event_type` (Enum) — Type of the event that occurred with the data part. Can have one of the following values:
|
||||
- `NEW_PART` — Inserting of a new data part.
|
||||
- `MERGE_PARTS` — Merging of data parts.
|
||||
- `DOWNLOAD_PART` — Downloading a data part.
|
||||
- `REMOVE_PART` — Removing or detaching a data part using [DETACH PARTITION](../../sql-reference/statements/alter.md#alter_detach-partition).
|
||||
- `MUTATE_PART` — Mutating of a data part.
|
||||
- `MOVE_PART` — Moving the data part from the one disk to another one.
|
||||
- `event_date` (Date) — Event date.
|
||||
- `event_time` (DateTime) — Event time.
|
||||
- `duration_ms` (UInt64) — Duration.
|
||||
- `database` (String) — Name of the database the data part is in.
|
||||
- `table` (String) — Name of the table the data part is in.
|
||||
- `part_name` (String) — Name of the data part.
|
||||
- `partition_id` (String) — ID of the partition that the data part was inserted to. The column takes the ‘all’ 值,如果分区是由 `tuple()`.
|
||||
- `rows` (UInt64) — The number of rows in the data part.
|
||||
- `size_in_bytes` (UInt64) — Size of the data part in bytes.
|
||||
- `merged_from` (Array(String)) — An array of names of the parts which the current part was made up from (after the merge).
|
||||
- `bytes_uncompressed` (UInt64) — Size of uncompressed bytes.
|
||||
- `read_rows` (UInt64) — The number of rows was read during the merge.
|
||||
- `read_bytes` (UInt64) — The number of bytes was read during the merge.
|
||||
- `error` (UInt16) — The code number of the occurred error.
|
||||
- `exception` (String) — Text message of the occurred error.
|
||||
|
||||
该 `system.part_log` 表的第一个插入数据到后创建 `MergeTree` 桌子
|
85
docs/zh/operations/system-tables/parts.md
Normal file
85
docs/zh/operations/system-tables/parts.md
Normal file
@ -0,0 +1,85 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。零件 {#system_tables-parts}
|
||||
|
||||
包含有关的部分信息 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 桌子
|
||||
|
||||
每行描述一个数据部分。
|
||||
|
||||
列:
|
||||
|
||||
- `partition` (String) – The partition name. To learn what a partition is, see the description of the [ALTER](../../sql-reference/statements/alter.md#query_language_queries_alter) 查询。
|
||||
|
||||
格式:
|
||||
|
||||
- `YYYYMM` 用于按月自动分区。
|
||||
- `any_string` 手动分区时。
|
||||
|
||||
- `name` (`String`) – Name of the data part.
|
||||
|
||||
- `active` (`UInt8`) – Flag that indicates whether the data part is active. If a data part is active, it's used in a table. Otherwise, it's deleted. Inactive data parts remain after merging.
|
||||
|
||||
- `marks` (`UInt64`) – The number of marks. To get the approximate number of rows in a data part, multiply `marks` 通过索引粒度(通常为8192)(此提示不适用于自适应粒度)。
|
||||
|
||||
- `rows` (`UInt64`) – The number of rows.
|
||||
|
||||
- `bytes_on_disk` (`UInt64`) – Total size of all the data part files in bytes.
|
||||
|
||||
- `data_compressed_bytes` (`UInt64`) – Total size of compressed data in the data part. All the auxiliary files (for example, files with marks) are not included.
|
||||
|
||||
- `data_uncompressed_bytes` (`UInt64`) – Total size of uncompressed data in the data part. All the auxiliary files (for example, files with marks) are not included.
|
||||
|
||||
- `marks_bytes` (`UInt64`) – The size of the file with marks.
|
||||
|
||||
- `modification_time` (`DateTime`) – The time the directory with the data part was modified. This usually corresponds to the time of data part creation.\|
|
||||
|
||||
- `remove_time` (`DateTime`) – The time when the data part became inactive.
|
||||
|
||||
- `refcount` (`UInt32`) – The number of places where the data part is used. A value greater than 2 indicates that the data part is used in queries or merges.
|
||||
|
||||
- `min_date` (`Date`) – The minimum value of the date key in the data part.
|
||||
|
||||
- `max_date` (`Date`) – The maximum value of the date key in the data part.
|
||||
|
||||
- `min_time` (`DateTime`) – The minimum value of the date and time key in the data part.
|
||||
|
||||
- `max_time`(`DateTime`) – The maximum value of the date and time key in the data part.
|
||||
|
||||
- `partition_id` (`String`) – ID of the partition.
|
||||
|
||||
- `min_block_number` (`UInt64`) – The minimum number of data parts that make up the current part after merging.
|
||||
|
||||
- `max_block_number` (`UInt64`) – The maximum number of data parts that make up the current part after merging.
|
||||
|
||||
- `level` (`UInt32`) – Depth of the merge tree. Zero means that the current part was created by insert rather than by merging other parts.
|
||||
|
||||
- `data_version` (`UInt64`) – Number that is used to determine which mutations should be applied to the data part (mutations with a version higher than `data_version`).
|
||||
|
||||
- `primary_key_bytes_in_memory` (`UInt64`) – The amount of memory (in bytes) used by primary key values.
|
||||
|
||||
- `primary_key_bytes_in_memory_allocated` (`UInt64`) – The amount of memory (in bytes) reserved for primary key values.
|
||||
|
||||
- `is_frozen` (`UInt8`) – Flag that shows that a partition data backup exists. 1, the backup exists. 0, the backup doesn't exist. For more details, see [FREEZE PARTITION](../../sql-reference/statements/alter.md#alter_freeze-partition)
|
||||
|
||||
- `database` (`String`) – Name of the database.
|
||||
|
||||
- `table` (`String`) – Name of the table.
|
||||
|
||||
- `engine` (`String`) – Name of the table engine without parameters.
|
||||
|
||||
- `path` (`String`) – Absolute path to the folder with data part files.
|
||||
|
||||
- `disk` (`String`) – Name of a disk that stores the data part.
|
||||
|
||||
- `hash_of_all_files` (`String`) – [sipHash128](../../sql-reference/functions/hash-functions.md#hash_functions-siphash128) 的压缩文件。
|
||||
|
||||
- `hash_of_uncompressed_files` (`String`) – [sipHash128](../../sql-reference/functions/hash-functions.md#hash_functions-siphash128) 未压缩的文件(带标记的文件,索引文件等。).
|
||||
|
||||
- `uncompressed_hash_of_compressed_files` (`String`) – [sipHash128](../../sql-reference/functions/hash-functions.md#hash_functions-siphash128) 压缩文件中的数据,就好像它们是未压缩的。
|
||||
|
||||
- `bytes` (`UInt64`) – Alias for `bytes_on_disk`.
|
||||
|
||||
- `marks_size` (`UInt64`) – Alias for `marks_bytes`.
|
20
docs/zh/operations/system-tables/processes.md
Normal file
20
docs/zh/operations/system-tables/processes.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。流程 {#system_tables-processes}
|
||||
|
||||
该系统表用于实现 `SHOW PROCESSLIST` 查询。
|
||||
|
||||
列:
|
||||
|
||||
- `user` (String) – The user who made the query. Keep in mind that for distributed processing, queries are sent to remote servers under the `default` 用户。 该字段包含特定查询的用户名,而不是此查询启动的查询的用户名。
|
||||
- `address` (String) – The IP address the request was made from. The same for distributed processing. To track where a distributed query was originally made from, look at `system.processes` 查询请求者服务器上。
|
||||
- `elapsed` (Float64) – The time in seconds since request execution started.
|
||||
- `rows_read` (UInt64) – The number of rows read from the table. For distributed processing, on the requestor server, this is the total for all remote servers.
|
||||
- `bytes_read` (UInt64) – The number of uncompressed bytes read from the table. For distributed processing, on the requestor server, this is the total for all remote servers.
|
||||
- `total_rows_approx` (UInt64) – The approximation of the total number of rows that should be read. For distributed processing, on the requestor server, this is the total for all remote servers. It can be updated during request processing, when new sources to process become known.
|
||||
- `memory_usage` (UInt64) – Amount of RAM the request uses. It might not include some types of dedicated memory. See the [max\_memory\_usage](../../operations/settings/query-complexity.md#settings_max_memory_usage) 设置。
|
||||
- `query` (String) – The query text. For `INSERT`,它不包括要插入的数据。
|
||||
- `query_id` (String) – Query ID, if defined.
|
143
docs/zh/operations/system-tables/query_log.md
Normal file
143
docs/zh/operations/system-tables/query_log.md
Normal file
@ -0,0 +1,143 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。query\_log {#system_tables-query_log}
|
||||
|
||||
包含有关已执行查询的信息,例如,开始时间、处理持续时间、错误消息。
|
||||
|
||||
!!! note "注"
|
||||
此表不包含以下内容的摄取数据 `INSERT` 查询。
|
||||
|
||||
您可以更改查询日志记录的设置 [query\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-query-log) 服务器配置部分。
|
||||
|
||||
您可以通过设置禁用查询日志记录 [log\_queries=0](../../operations/settings/settings.md#settings-log-queries). 我们不建议关闭日志记录,因为此表中的信息对于解决问题很重要。
|
||||
|
||||
数据的冲洗周期设置在 `flush_interval_milliseconds` 的参数 [query\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-query-log) 服务器设置部分。 要强制冲洗,请使用 [SYSTEM FLUSH LOGS](../../sql-reference/statements/system.md#query_language-system-flush_logs) 查询。
|
||||
|
||||
ClickHouse不会自动从表中删除数据。 看 [导言](../../operations/system-tables/index.md#system-tables-introduction) 欲了解更多详情。
|
||||
|
||||
该 `system.query_log` 表注册两种查询:
|
||||
|
||||
1. 客户端直接运行的初始查询。
|
||||
2. 由其他查询启动的子查询(用于分布式查询执行)。 对于这些类型的查询,有关父查询的信息显示在 `initial_*` 列。
|
||||
|
||||
每个查询创建一个或两个行中 `query_log` 表,这取决于状态(见 `type` 列)的查询:
|
||||
|
||||
1. 如果查询执行成功,则两行具有 `QueryStart` 和 `QueryFinish` 创建类型。
|
||||
2. 如果在查询处理过程中发生错误,两个事件与 `QueryStart` 和 `ExceptionWhileProcessing` 创建类型。
|
||||
3. 如果在启动查询之前发生错误,则单个事件具有 `ExceptionBeforeStart` 创建类型。
|
||||
|
||||
列:
|
||||
|
||||
- `type` ([枚举8](../../sql-reference/data-types/enum.md)) — Type of an event that occurred when executing the query. Values:
|
||||
- `'QueryStart' = 1` — Successful start of query execution.
|
||||
- `'QueryFinish' = 2` — Successful end of query execution.
|
||||
- `'ExceptionBeforeStart' = 3` — Exception before the start of query execution.
|
||||
- `'ExceptionWhileProcessing' = 4` — Exception during the query execution.
|
||||
- `event_date` ([日期](../../sql-reference/data-types/date.md)) — Query starting date.
|
||||
- `event_time` ([日期时间](../../sql-reference/data-types/datetime.md)) — Query starting time.
|
||||
- `query_start_time` ([日期时间](../../sql-reference/data-types/datetime.md)) — Start time of query execution.
|
||||
- `query_duration_ms` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Duration of query execution in milliseconds.
|
||||
- `read_rows` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Total number or rows read from all tables and table functions participated in query. It includes usual subqueries, subqueries for `IN` 和 `JOIN`. 对于分布式查询 `read_rows` 包括在所有副本上读取的行总数。 每个副本发送它的 `read_rows` 值,并且查询的服务器-发起方汇总所有接收到的和本地的值。 缓存卷不会影响此值。
|
||||
- `read_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Total number or bytes read from all tables and table functions participated in query. It includes usual subqueries, subqueries for `IN` 和 `JOIN`. 对于分布式查询 `read_bytes` 包括在所有副本上读取的行总数。 每个副本发送它的 `read_bytes` 值,并且查询的服务器-发起方汇总所有接收到的和本地的值。 缓存卷不会影响此值。
|
||||
- `written_rows` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` 查询,写入的行数。 对于其他查询,列值为0。
|
||||
- `written_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` 查询时,写入的字节数。 对于其他查询,列值为0。
|
||||
- `result_rows` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of rows in a result of the `SELECT` 查询,或者在一些行 `INSERT` 查询。
|
||||
- `result_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — RAM volume in bytes used to store a query result.
|
||||
- `memory_usage` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Memory consumption by the query.
|
||||
- `query` ([字符串](../../sql-reference/data-types/string.md)) — Query string.
|
||||
- `exception` ([字符串](../../sql-reference/data-types/string.md)) — Exception message.
|
||||
- `exception_code` ([Int32](../../sql-reference/data-types/int-uint.md)) — Code of an exception.
|
||||
- `stack_trace` ([字符串](../../sql-reference/data-types/string.md)) — [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace). 如果查询成功完成,则为空字符串。
|
||||
- `is_initial_query` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Query type. Possible values:
|
||||
- 1 — Query was initiated by the client.
|
||||
- 0 — Query was initiated by another query as part of distributed query execution.
|
||||
- `user` ([字符串](../../sql-reference/data-types/string.md)) — Name of the user who initiated the current query.
|
||||
- `query_id` ([字符串](../../sql-reference/data-types/string.md)) — ID of the query.
|
||||
- `address` ([IPv6](../../sql-reference/data-types/domains/ipv6.md)) — IP address that was used to make the query.
|
||||
- `port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — The client port that was used to make the query.
|
||||
- `initial_user` ([字符串](../../sql-reference/data-types/string.md)) — Name of the user who ran the initial query (for distributed query execution).
|
||||
- `initial_query_id` ([字符串](../../sql-reference/data-types/string.md)) — ID of the initial query (for distributed query execution).
|
||||
- `initial_address` ([IPv6](../../sql-reference/data-types/domains/ipv6.md)) — IP address that the parent query was launched from.
|
||||
- `initial_port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — The client port that was used to make the parent query.
|
||||
- `interface` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Interface that the query was initiated from. Possible values:
|
||||
- 1 — TCP.
|
||||
- 2 — HTTP.
|
||||
- `os_user` ([字符串](../../sql-reference/data-types/string.md)) — Operating system username who runs [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md).
|
||||
- `client_hostname` ([字符串](../../sql-reference/data-types/string.md)) — Hostname of the client machine where the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或者运行另一个TCP客户端。
|
||||
- `client_name` ([字符串](../../sql-reference/data-types/string.md)) — The [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端名称。
|
||||
- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Revision of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端。
|
||||
- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Major version of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端。
|
||||
- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Minor version of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端。
|
||||
- `client_version_patch` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Patch component of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端版本。
|
||||
- `http_method` (UInt8) — HTTP method that initiated the query. Possible values:
|
||||
- 0 — The query was launched from the TCP interface.
|
||||
- 1 — `GET` 方法被使用。
|
||||
- 2 — `POST` 方法被使用。
|
||||
- `http_user_agent` ([字符串](../../sql-reference/data-types/string.md)) — The `UserAgent` http请求中传递的标头。
|
||||
- `quota_key` ([字符串](../../sql-reference/data-types/string.md)) — The “quota key” 在指定 [配额](../../operations/quotas.md) 设置(见 `keyed`).
|
||||
- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse revision.
|
||||
- `thread_numbers` ([数组(UInt32)](../../sql-reference/data-types/array.md)) — Number of threads that are participating in query execution.
|
||||
- `ProfileEvents.Names` ([数组(字符串)](../../sql-reference/data-types/array.md)) — Counters that measure different metrics. The description of them could be found in the table [系统。活动](../../operations/system-tables/events.md#system_tables-events)
|
||||
- `ProfileEvents.Values` ([数组(UInt64)](../../sql-reference/data-types/array.md)) — Values of metrics that are listed in the `ProfileEvents.Names` 列。
|
||||
- `Settings.Names` ([数组(字符串)](../../sql-reference/data-types/array.md)) — Names of settings that were changed when the client ran the query. To enable logging changes to settings, set the `log_query_settings` 参数为1。
|
||||
- `Settings.Values` ([数组(字符串)](../../sql-reference/data-types/array.md)) — Values of settings that are listed in the `Settings.Names` 列。
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.query_log LIMIT 1 FORMAT Vertical;
|
||||
```
|
||||
|
||||
``` text
|
||||
Row 1:
|
||||
──────
|
||||
type: QueryStart
|
||||
event_date: 2020-05-13
|
||||
event_time: 2020-05-13 14:02:28
|
||||
query_start_time: 2020-05-13 14:02:28
|
||||
query_duration_ms: 0
|
||||
read_rows: 0
|
||||
read_bytes: 0
|
||||
written_rows: 0
|
||||
written_bytes: 0
|
||||
result_rows: 0
|
||||
result_bytes: 0
|
||||
memory_usage: 0
|
||||
query: SELECT 1
|
||||
exception_code: 0
|
||||
exception:
|
||||
stack_trace:
|
||||
is_initial_query: 1
|
||||
user: default
|
||||
query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a
|
||||
address: ::ffff:127.0.0.1
|
||||
port: 57720
|
||||
initial_user: default
|
||||
initial_query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a
|
||||
initial_address: ::ffff:127.0.0.1
|
||||
initial_port: 57720
|
||||
interface: 1
|
||||
os_user: bayonet
|
||||
client_hostname: clickhouse.ru-central1.internal
|
||||
client_name: ClickHouse client
|
||||
client_revision: 54434
|
||||
client_version_major: 20
|
||||
client_version_minor: 4
|
||||
client_version_patch: 1
|
||||
http_method: 0
|
||||
http_user_agent:
|
||||
quota_key:
|
||||
revision: 54434
|
||||
thread_ids: []
|
||||
ProfileEvents.Names: []
|
||||
ProfileEvents.Values: []
|
||||
Settings.Names: ['use_uncompressed_cache','load_balancing','log_queries','max_memory_usage']
|
||||
Settings.Values: ['0','random','1','10000000000']
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [系统。query\_thread\_log](../../operations/system-tables/query_thread_log.md#system_tables-query_thread_log) — This table contains information about each query execution thread.
|
118
docs/zh/operations/system-tables/query_thread_log.md
Normal file
118
docs/zh/operations/system-tables/query_thread_log.md
Normal file
@ -0,0 +1,118 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。query\_thread\_log {#system_tables-query_thread_log}
|
||||
|
||||
包含有关执行查询的线程的信息,例如,线程名称、线程开始时间、查询处理的持续时间。
|
||||
|
||||
开始记录:
|
||||
|
||||
1. 在配置参数 [query\_thread\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log) 科。
|
||||
2. 设置 [log\_query\_threads](../../operations/settings/settings.md#settings-log-query-threads) 到1。
|
||||
|
||||
数据的冲洗周期设置在 `flush_interval_milliseconds` 的参数 [query\_thread\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log) 服务器设置部分。 要强制冲洗,请使用 [SYSTEM FLUSH LOGS](../../sql-reference/statements/system.md#query_language-system-flush_logs) 查询。
|
||||
|
||||
ClickHouse不会自动从表中删除数据。 看 [导言](../../operations/system-tables/index.md#system-tables-introduction) 欲了解更多详情。
|
||||
|
||||
列:
|
||||
|
||||
- `event_date` ([日期](../../sql-reference/data-types/date.md)) — The date when the thread has finished execution of the query.
|
||||
- `event_time` ([日期时间](../../sql-reference/data-types/datetime.md)) — The date and time when the thread has finished execution of the query.
|
||||
- `query_start_time` ([日期时间](../../sql-reference/data-types/datetime.md)) — Start time of query execution.
|
||||
- `query_duration_ms` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Duration of query execution.
|
||||
- `read_rows` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of read rows.
|
||||
- `read_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Number of read bytes.
|
||||
- `written_rows` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` 查询,写入的行数。 对于其他查询,列值为0。
|
||||
- `written_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — For `INSERT` 查询时,写入的字节数。 对于其他查询,列值为0。
|
||||
- `memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — The difference between the amount of allocated and freed memory in context of this thread.
|
||||
- `peak_memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — The maximum difference between the amount of allocated and freed memory in context of this thread.
|
||||
- `thread_name` ([字符串](../../sql-reference/data-types/string.md)) — Name of the thread.
|
||||
- `thread_number` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Internal thread ID.
|
||||
- `thread_id` ([Int32](../../sql-reference/data-types/int-uint.md)) — thread ID.
|
||||
- `master_thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — OS initial ID of initial thread.
|
||||
- `query` ([字符串](../../sql-reference/data-types/string.md)) — Query string.
|
||||
- `is_initial_query` ([UInt8](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Query type. Possible values:
|
||||
- 1 — Query was initiated by the client.
|
||||
- 0 — Query was initiated by another query for distributed query execution.
|
||||
- `user` ([字符串](../../sql-reference/data-types/string.md)) — Name of the user who initiated the current query.
|
||||
- `query_id` ([字符串](../../sql-reference/data-types/string.md)) — ID of the query.
|
||||
- `address` ([IPv6](../../sql-reference/data-types/domains/ipv6.md)) — IP address that was used to make the query.
|
||||
- `port` ([UInt16](../../sql-reference/data-types/int-uint.md#uint-ranges)) — The client port that was used to make the query.
|
||||
- `initial_user` ([字符串](../../sql-reference/data-types/string.md)) — Name of the user who ran the initial query (for distributed query execution).
|
||||
- `initial_query_id` ([字符串](../../sql-reference/data-types/string.md)) — ID of the initial query (for distributed query execution).
|
||||
- `initial_address` ([IPv6](../../sql-reference/data-types/domains/ipv6.md)) — IP address that the parent query was launched from.
|
||||
- `initial_port` ([UInt16](../../sql-reference/data-types/int-uint.md#uint-ranges)) — The client port that was used to make the parent query.
|
||||
- `interface` ([UInt8](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Interface that the query was initiated from. Possible values:
|
||||
- 1 — TCP.
|
||||
- 2 — HTTP.
|
||||
- `os_user` ([字符串](../../sql-reference/data-types/string.md)) — OS's username who runs [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md).
|
||||
- `client_hostname` ([字符串](../../sql-reference/data-types/string.md)) — Hostname of the client machine where the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或者运行另一个TCP客户端。
|
||||
- `client_name` ([字符串](../../sql-reference/data-types/string.md)) — The [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端名称。
|
||||
- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Revision of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端。
|
||||
- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Major version of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端。
|
||||
- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Minor version of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端。
|
||||
- `client_version_patch` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Patch component of the [ツ环板clientョツ嘉ッツ偲](../../interfaces/cli.md) 或另一个TCP客户端版本。
|
||||
- `http_method` ([UInt8](../../sql-reference/data-types/int-uint.md#uint-ranges)) — HTTP method that initiated the query. Possible values:
|
||||
- 0 — The query was launched from the TCP interface.
|
||||
- 1 — `GET` 方法被使用。
|
||||
- 2 — `POST` 方法被使用。
|
||||
- `http_user_agent` ([字符串](../../sql-reference/data-types/string.md)) — The `UserAgent` http请求中传递的标头。
|
||||
- `quota_key` ([字符串](../../sql-reference/data-types/string.md)) — The “quota key” 在指定 [配额](../../operations/quotas.md) 设置(见 `keyed`).
|
||||
- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse revision.
|
||||
- `ProfileEvents.Names` ([数组(字符串)](../../sql-reference/data-types/array.md)) — Counters that measure different metrics for this thread. The description of them could be found in the table [系统。活动](#system_tables-events).
|
||||
- `ProfileEvents.Values` ([数组(UInt64)](../../sql-reference/data-types/array.md)) — Values of metrics for this thread that are listed in the `ProfileEvents.Names` 列。
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.query_thread_log LIMIT 1 FORMAT Vertical
|
||||
```
|
||||
|
||||
``` text
|
||||
Row 1:
|
||||
──────
|
||||
event_date: 2020-05-13
|
||||
event_time: 2020-05-13 14:02:28
|
||||
query_start_time: 2020-05-13 14:02:28
|
||||
query_duration_ms: 0
|
||||
read_rows: 1
|
||||
read_bytes: 1
|
||||
written_rows: 0
|
||||
written_bytes: 0
|
||||
memory_usage: 0
|
||||
peak_memory_usage: 0
|
||||
thread_name: QueryPipelineEx
|
||||
thread_id: 28952
|
||||
master_thread_id: 28924
|
||||
query: SELECT 1
|
||||
is_initial_query: 1
|
||||
user: default
|
||||
query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a
|
||||
address: ::ffff:127.0.0.1
|
||||
port: 57720
|
||||
initial_user: default
|
||||
initial_query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a
|
||||
initial_address: ::ffff:127.0.0.1
|
||||
initial_port: 57720
|
||||
interface: 1
|
||||
os_user: bayonet
|
||||
client_hostname: clickhouse.ru-central1.internal
|
||||
client_name: ClickHouse client
|
||||
client_revision: 54434
|
||||
client_version_major: 20
|
||||
client_version_minor: 4
|
||||
client_version_patch: 1
|
||||
http_method: 0
|
||||
http_user_agent:
|
||||
quota_key:
|
||||
revision: 54434
|
||||
ProfileEvents.Names: ['ContextLock','RealTimeMicroseconds','UserTimeMicroseconds','OSCPUWaitMicroseconds','OSCPUVirtualTimeMicroseconds']
|
||||
ProfileEvents.Values: [1,97,81,5,81]
|
||||
...
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [系统。query\_log](../../operations/system-tables/query_log.md#system_tables-query_log) — Description of the `query_log` 系统表,其中包含有关查询执行的公共信息。
|
126
docs/zh/operations/system-tables/replicas.md
Normal file
126
docs/zh/operations/system-tables/replicas.md
Normal file
@ -0,0 +1,126 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。副本 {#system_tables-replicas}
|
||||
|
||||
包含驻留在本地服务器上的复制表的信息和状态。
|
||||
此表可用于监视。 该表对于每个已复制的\*表都包含一行。
|
||||
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT *
|
||||
FROM system.replicas
|
||||
WHERE table = 'visits'
|
||||
FORMAT Vertical
|
||||
```
|
||||
|
||||
``` text
|
||||
Row 1:
|
||||
──────
|
||||
database: merge
|
||||
table: visits
|
||||
engine: ReplicatedCollapsingMergeTree
|
||||
is_leader: 1
|
||||
can_become_leader: 1
|
||||
is_readonly: 0
|
||||
is_session_expired: 0
|
||||
future_parts: 1
|
||||
parts_to_check: 0
|
||||
zookeeper_path: /clickhouse/tables/01-06/visits
|
||||
replica_name: example01-06-1.yandex.ru
|
||||
replica_path: /clickhouse/tables/01-06/visits/replicas/example01-06-1.yandex.ru
|
||||
columns_version: 9
|
||||
queue_size: 1
|
||||
inserts_in_queue: 0
|
||||
merges_in_queue: 1
|
||||
part_mutations_in_queue: 0
|
||||
queue_oldest_time: 2020-02-20 08:34:30
|
||||
inserts_oldest_time: 0000-00-00 00:00:00
|
||||
merges_oldest_time: 2020-02-20 08:34:30
|
||||
part_mutations_oldest_time: 0000-00-00 00:00:00
|
||||
oldest_part_to_get:
|
||||
oldest_part_to_merge_to: 20200220_20284_20840_7
|
||||
oldest_part_to_mutate_to:
|
||||
log_max_index: 596273
|
||||
log_pointer: 596274
|
||||
last_queue_update: 2020-02-20 08:34:32
|
||||
absolute_delay: 0
|
||||
total_replicas: 2
|
||||
active_replicas: 2
|
||||
```
|
||||
|
||||
列:
|
||||
|
||||
- `database` (`String`)-数据库名称
|
||||
- `table` (`String`)-表名
|
||||
- `engine` (`String`)-表引擎名称
|
||||
- `is_leader` (`UInt8`)-副本是否是领导者。
|
||||
一次只有一个副本可以成为领导者。 领导者负责选择要执行的后台合并。
|
||||
请注意,可以对任何可用且在ZK中具有会话的副本执行写操作,而不管该副本是否为leader。
|
||||
- `can_become_leader` (`UInt8`)-副本是否可以当选为领导者。
|
||||
- `is_readonly` (`UInt8`)-副本是否处于只读模式。
|
||||
如果配置没有ZooKeeper的部分,如果在ZooKeeper中重新初始化会话时发生未知错误,以及在ZooKeeper中重新初始化会话时发生未知错误,则此模式将打开。
|
||||
- `is_session_expired` (`UInt8`)-与ZooKeeper的会话已经过期。 基本上一样 `is_readonly`.
|
||||
- `future_parts` (`UInt32`)-由于尚未完成的插入或合并而显示的数据部分的数量。
|
||||
- `parts_to_check` (`UInt32`)-队列中用于验证的数据部分的数量。 如果怀疑零件可能已损坏,则将其放入验证队列。
|
||||
- `zookeeper_path` (`String`)-在ZooKeeper中的表数据路径。
|
||||
- `replica_name` (`String`)-在动物园管理员副本名称. 同一表的不同副本具有不同的名称。
|
||||
- `replica_path` (`String`)-在ZooKeeper中的副本数据的路径。 与连接相同 ‘zookeeper\_path/replicas/replica\_path’.
|
||||
- `columns_version` (`Int32`)-表结构的版本号。 指示执行ALTER的次数。 如果副本有不同的版本,这意味着一些副本还没有做出所有的改变。
|
||||
- `queue_size` (`UInt32`)-等待执行的操作的队列大小。 操作包括插入数据块、合并和某些其他操作。 它通常与 `future_parts`.
|
||||
- `inserts_in_queue` (`UInt32`)-需要插入数据块的数量。 插入通常复制得相当快。 如果这个数字很大,这意味着有什么不对劲。
|
||||
- `merges_in_queue` (`UInt32`)-等待进行合并的数量。 有时合并时间很长,因此此值可能长时间大于零。
|
||||
- `part_mutations_in_queue` (`UInt32`)-等待进行的突变的数量。
|
||||
- `queue_oldest_time` (`DateTime`)-如果 `queue_size` 大于0,显示何时将最旧的操作添加到队列中。
|
||||
- `inserts_oldest_time` (`DateTime`)-看 `queue_oldest_time`
|
||||
- `merges_oldest_time` (`DateTime`)-看 `queue_oldest_time`
|
||||
- `part_mutations_oldest_time` (`DateTime`)-看 `queue_oldest_time`
|
||||
|
||||
接下来的4列只有在有ZK活动会话的情况下才具有非零值。
|
||||
|
||||
- `log_max_index` (`UInt64`)-一般活动日志中的最大条目数。
|
||||
- `log_pointer` (`UInt64`)-副本复制到其执行队列的常规活动日志中的最大条目数加一。 如果 `log_pointer` 比 `log_max_index`,有点不对劲。
|
||||
- `last_queue_update` (`DateTime`)-上次更新队列时。
|
||||
- `absolute_delay` (`UInt64`)-当前副本有多大滞后秒。
|
||||
- `total_replicas` (`UInt8`)-此表的已知副本总数。
|
||||
- `active_replicas` (`UInt8`)-在ZooKeeper中具有会话的此表的副本的数量(即正常运行的副本的数量)。
|
||||
|
||||
如果您请求所有列,表可能会工作得有点慢,因为每行都会从ZooKeeper进行几次读取。
|
||||
如果您没有请求最后4列(log\_max\_index,log\_pointer,total\_replicas,active\_replicas),表工作得很快。
|
||||
|
||||
例如,您可以检查一切是否正常工作,如下所示:
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
database,
|
||||
table,
|
||||
is_leader,
|
||||
is_readonly,
|
||||
is_session_expired,
|
||||
future_parts,
|
||||
parts_to_check,
|
||||
columns_version,
|
||||
queue_size,
|
||||
inserts_in_queue,
|
||||
merges_in_queue,
|
||||
log_max_index,
|
||||
log_pointer,
|
||||
total_replicas,
|
||||
active_replicas
|
||||
FROM system.replicas
|
||||
WHERE
|
||||
is_readonly
|
||||
OR is_session_expired
|
||||
OR future_parts > 20
|
||||
OR parts_to_check > 10
|
||||
OR queue_size > 20
|
||||
OR inserts_in_queue > 10
|
||||
OR log_max_index - log_pointer > 10
|
||||
OR total_replicas < 2
|
||||
OR active_replicas < total_replicas
|
||||
```
|
||||
|
||||
如果这个查询没有返回任何东西,这意味着一切都很好。
|
55
docs/zh/operations/system-tables/settings.md
Normal file
55
docs/zh/operations/system-tables/settings.md
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。设置 {#system-tables-system-settings}
|
||||
|
||||
包含有关当前用户的会话设置的信息。
|
||||
|
||||
列:
|
||||
|
||||
- `name` ([字符串](../../sql-reference/data-types/string.md)) — Setting name.
|
||||
- `value` ([字符串](../../sql-reference/data-types/string.md)) — Setting value.
|
||||
- `changed` ([UInt8](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether a setting is changed from its default value.
|
||||
- `description` ([字符串](../../sql-reference/data-types/string.md)) — Short setting description.
|
||||
- `min` ([可为空](../../sql-reference/data-types/nullable.md)([字符串](../../sql-reference/data-types/string.md))) — Minimum value of the setting, if any is set via [制约因素](../../operations/settings/constraints-on-settings.md#constraints-on-settings). 如果设置没有最小值,则包含 [NULL](../../sql-reference/syntax.md#null-literal).
|
||||
- `max` ([可为空](../../sql-reference/data-types/nullable.md)([字符串](../../sql-reference/data-types/string.md))) — Maximum value of the setting, if any is set via [制约因素](../../operations/settings/constraints-on-settings.md#constraints-on-settings). 如果设置没有最大值,则包含 [NULL](../../sql-reference/syntax.md#null-literal).
|
||||
- `readonly` ([UInt8](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Shows whether the current user can change the setting:
|
||||
- `0` — Current user can change the setting.
|
||||
- `1` — Current user can't change the setting.
|
||||
|
||||
**示例**
|
||||
|
||||
下面的示例演示如何获取有关名称包含的设置的信息 `min_i`.
|
||||
|
||||
``` sql
|
||||
SELECT *
|
||||
FROM system.settings
|
||||
WHERE name LIKE '%min_i%'
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─name────────────────────────────────────────┬─value─────┬─changed─┬─description───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─min──┬─max──┬─readonly─┐
|
||||
│ min_insert_block_size_rows │ 1048576 │ 0 │ Squash blocks passed to INSERT query to specified size in rows, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │
|
||||
│ min_insert_block_size_bytes │ 268435456 │ 0 │ Squash blocks passed to INSERT query to specified size in bytes, if blocks are not big enough. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │
|
||||
│ read_backoff_min_interval_between_events_ms │ 1000 │ 0 │ Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 0 │
|
||||
└─────────────────────────────────────────────┴───────────┴─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┴──────┴──────────┘
|
||||
```
|
||||
|
||||
使用 `WHERE changed` 可以是有用的,例如,当你想检查:
|
||||
|
||||
- 配置文件中的设置是否正确加载并正在使用。
|
||||
- 在当前会话中更改的设置。
|
||||
|
||||
<!-- -->
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.settings WHERE changed AND name='load_balancing'
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- [设置](../../operations/settings/index.md#session-settings-intro)
|
||||
- [查询权限](../../operations/settings/permissions-for-queries.md#settings_readonly)
|
||||
- [对设置的限制](../../operations/settings/constraints-on-settings.md)
|
19
docs/zh/operations/system-tables/storage_policies.md
Normal file
19
docs/zh/operations/system-tables/storage_policies.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。storage\_policies {#system_tables-storage_policies}
|
||||
|
||||
包含有关存储策略和卷中定义的信息 [服务器配置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure).
|
||||
|
||||
列:
|
||||
|
||||
- `policy_name` ([字符串](../../sql-reference/data-types/string.md)) — Name of the storage policy.
|
||||
- `volume_name` ([字符串](../../sql-reference/data-types/string.md)) — Volume name defined in the storage policy.
|
||||
- `volume_priority` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Volume order number in the configuration.
|
||||
- `disks` ([数组(字符串)](../../sql-reference/data-types/array.md)) — Disk names, defined in the storage policy.
|
||||
- `max_data_part_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Maximum size of a data part that can be stored on volume disks (0 — no limit).
|
||||
- `move_factor` ([Float64](../../sql-reference/data-types/float.md)) — Ratio of free disk space. When the ratio exceeds the value of configuration parameter, ClickHouse start to move data to the next volume in order.
|
||||
|
||||
如果存储策略包含多个卷,则每个卷的信息将存储在表的单独行中。
|
40
docs/zh/operations/system-tables/table_engines.md
Normal file
40
docs/zh/operations/system-tables/table_engines.md
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。表\_engines {#system-table-engines}
|
||||
|
||||
包含服务器支持的表引擎的描述及其功能支持信息。
|
||||
|
||||
此表包含以下列(列类型显示在括号中):
|
||||
|
||||
- `name` (String) — The name of table engine.
|
||||
- `supports_settings` (UInt8) — Flag that indicates if table engine supports `SETTINGS` 条款
|
||||
- `supports_skipping_indices` (UInt8) — Flag that indicates if table engine supports [跳过索引](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes).
|
||||
- `supports_ttl` (UInt8) — Flag that indicates if table engine supports [TTL](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl).
|
||||
- `supports_sort_order` (UInt8) — Flag that indicates if table engine supports clauses `PARTITION_BY`, `PRIMARY_KEY`, `ORDER_BY` 和 `SAMPLE_BY`.
|
||||
- `supports_replication` (UInt8) — Flag that indicates if table engine supports [数据复制](../../engines/table-engines/mergetree-family/replication.md).
|
||||
- `supports_duduplication` (UInt8) — Flag that indicates if table engine supports data deduplication.
|
||||
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT *
|
||||
FROM system.table_engines
|
||||
WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree')
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─name──────────────────────────┬─supports_settings─┬─supports_skipping_indices─┬─supports_sort_order─┬─supports_ttl─┬─supports_replication─┬─supports_deduplication─┐
|
||||
│ Kafka │ 1 │ 0 │ 0 │ 0 │ 0 │ 0 │
|
||||
│ MergeTree │ 1 │ 1 │ 1 │ 1 │ 0 │ 0 │
|
||||
│ ReplicatedCollapsingMergeTree │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │
|
||||
└───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┘
|
||||
```
|
||||
|
||||
**另请参阅**
|
||||
|
||||
- 梅树家族 [查询子句](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses)
|
||||
- 卡夫卡 [设置](../../engines/table-engines/integrations/kafka.md#table_engine-kafka-creating-a-table)
|
||||
- 加入我们 [设置](../../engines/table-engines/special/join.md#join-limitations-and-settings)
|
54
docs/zh/operations/system-tables/tables.md
Normal file
54
docs/zh/operations/system-tables/tables.md
Normal file
@ -0,0 +1,54 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。表 {#system-tables}
|
||||
|
||||
包含服务器知道的每个表的元数据。 分离的表不显示在 `system.tables`.
|
||||
|
||||
此表包含以下列(列类型显示在括号中):
|
||||
|
||||
- `database` (String) — The name of the database the table is in.
|
||||
|
||||
- `name` (String) — Table name.
|
||||
|
||||
- `engine` (String) — Table engine name (without parameters).
|
||||
|
||||
- `is_temporary` (UInt8)-指示表是否是临时的标志。
|
||||
|
||||
- `data_path` (String)-文件系统中表数据的路径。
|
||||
|
||||
- `metadata_path` (String)-文件系统中表元数据的路径。
|
||||
|
||||
- `metadata_modification_time` (DateTime)-表元数据的最新修改时间。
|
||||
|
||||
- `dependencies_database` (数组(字符串))-数据库依赖关系.
|
||||
|
||||
- `dependencies_table` (数组(字符串))-表依赖关系 ([MaterializedView](../../engines/table-engines/special/materializedview.md) 基于当前表的表)。
|
||||
|
||||
- `create_table_query` (String)-用于创建表的查询。
|
||||
|
||||
- `engine_full` (String)-表引擎的参数。
|
||||
|
||||
- `partition_key` (String)-表中指定的分区键表达式。
|
||||
|
||||
- `sorting_key` (String)-表中指定的排序键表达式。
|
||||
|
||||
- `primary_key` (String)-表中指定的主键表达式。
|
||||
|
||||
- `sampling_key` (String)-表中指定的采样键表达式。
|
||||
|
||||
- `storage_policy` (字符串)-存储策略:
|
||||
|
||||
- [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes)
|
||||
- [分布](../../engines/table-engines/special/distributed.md#distributed)
|
||||
|
||||
- `total_rows` (Nullable(UInt64))-总行数,如果可以快速确定表中的确切行数,否则 `Null` (包括内衣 `Buffer` 表)。
|
||||
|
||||
- `total_bytes` (Nullable(UInt64))-总字节数,如果可以快速确定存储表的确切字节数,否则 `Null` (**不** 包括任何底层存储)。
|
||||
|
||||
- If the table stores data on disk, returns used space on disk (i.e. compressed).
|
||||
- 如果表在内存中存储数据,返回在内存中使用的近似字节数.
|
||||
|
||||
该 `system.tables` 表中使用 `SHOW TABLES` 查询实现。
|
31
docs/zh/operations/system-tables/text_log.md
Normal file
31
docs/zh/operations/system-tables/text_log.md
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。text\_log {#system-tables-text-log}
|
||||
|
||||
包含日志记录条目。 进入该表的日志记录级别可以通过以下方式进行限制 `text_log.level` 服务器设置。
|
||||
|
||||
列:
|
||||
|
||||
- `event_date` (Date) — Date of the entry.
|
||||
- `event_time` (DateTime) — Time of the entry.
|
||||
- `microseconds` (UInt32) — Microseconds of the entry.
|
||||
- `thread_name` (String) — Name of the thread from which the logging was done.
|
||||
- `thread_id` (UInt64) — OS thread ID.
|
||||
- `level` (`Enum8`) — Entry level. Possible values:
|
||||
- `1` 或 `'Fatal'`.
|
||||
- `2` 或 `'Critical'`.
|
||||
- `3` 或 `'Error'`.
|
||||
- `4` 或 `'Warning'`.
|
||||
- `5` 或 `'Notice'`.
|
||||
- `6` 或 `'Information'`.
|
||||
- `7` 或 `'Debug'`.
|
||||
- `8` 或 `'Trace'`.
|
||||
- `query_id` (String) — ID of the query.
|
||||
- `logger_name` (LowCardinality(String)) — Name of the logger (i.e. `DDLWorker`).
|
||||
- `message` (String) — The message itself.
|
||||
- `revision` (UInt32) — ClickHouse revision.
|
||||
- `source_file` (LowCardinality(String)) — Source file from which the logging was done.
|
||||
- `source_line` (UInt64) — Source line from which the logging was done.
|
53
docs/zh/operations/system-tables/trace_log.md
Normal file
53
docs/zh/operations/system-tables/trace_log.md
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。trace\_log {#system_tables-trace_log}
|
||||
|
||||
包含采样查询探查器收集的堆栈跟踪。
|
||||
|
||||
ClickHouse创建此表时 [trace\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-trace_log) 服务器配置部分被设置。 也是 [query\_profiler\_real\_time\_period\_ns](../../operations/settings/settings.md#query_profiler_real_time_period_ns) 和 [query\_profiler\_cpu\_time\_period\_ns](../../operations/settings/settings.md#query_profiler_cpu_time_period_ns) 应设置设置。
|
||||
|
||||
要分析日志,请使用 `addressToLine`, `addressToSymbol` 和 `demangle` 内省功能。
|
||||
|
||||
列:
|
||||
|
||||
- `event_date` ([日期](../../sql-reference/data-types/date.md)) — Date of sampling moment.
|
||||
|
||||
- `event_time` ([日期时间](../../sql-reference/data-types/datetime.md)) — Timestamp of the sampling moment.
|
||||
|
||||
- `timestamp_ns` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Timestamp of the sampling moment in nanoseconds.
|
||||
|
||||
- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse server build revision.
|
||||
|
||||
通过以下方式连接到服务器 `clickhouse-client`,你看到的字符串类似于 `Connected to ClickHouse server version 19.18.1 revision 54429.`. 该字段包含 `revision`,但不是 `version` 的服务器。
|
||||
|
||||
- `timer_type` ([枚举8](../../sql-reference/data-types/enum.md)) — Timer type:
|
||||
|
||||
- `Real` 表示挂钟时间。
|
||||
- `CPU` 表示CPU时间。
|
||||
|
||||
- `thread_number` ([UInt32](../../sql-reference/data-types/int-uint.md)) — Thread identifier.
|
||||
|
||||
- `query_id` ([字符串](../../sql-reference/data-types/string.md)) — Query identifier that can be used to get details about a query that was running from the [query\_log](#system_tables-query_log) 系统表.
|
||||
|
||||
- `trace` ([数组(UInt64)](../../sql-reference/data-types/array.md)) — Stack trace at the moment of sampling. Each element is a virtual memory address inside ClickHouse server process.
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
SELECT * FROM system.trace_log LIMIT 1 \G
|
||||
```
|
||||
|
||||
``` text
|
||||
Row 1:
|
||||
──────
|
||||
event_date: 2019-11-15
|
||||
event_time: 2019-11-15 15:09:38
|
||||
revision: 54428
|
||||
timer_type: Real
|
||||
thread_number: 48
|
||||
query_id: acc4d61f-5bd1-4a3e-bc91-2180be37c915
|
||||
trace: [94222141367858,94222152240175,94222152325351,94222152329944,94222152330796,94222151449980,94222144088167,94222151682763,94222144088167,94222151682763,94222144088167,94222144058283,94222144059248,94222091840750,94222091842302,94222091831228,94222189631488,140509950166747,140509942945935]
|
||||
```
|
75
docs/zh/operations/system-tables/zookeeper.md
Normal file
75
docs/zh/operations/system-tables/zookeeper.md
Normal file
@ -0,0 +1,75 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 系统。动物园管理员 {#system-zookeeper}
|
||||
|
||||
如果未配置ZooKeeper,则表不存在。 允许从配置中定义的ZooKeeper集群读取数据。
|
||||
查询必须具有 ‘path’ WHERE子句中的平等条件。 这是ZooKeeper中您想要获取数据的孩子的路径。
|
||||
|
||||
查询 `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` 输出对所有孩子的数据 `/clickhouse` 节点。
|
||||
要输出所有根节点的数据,write path= ‘/’.
|
||||
如果在指定的路径 ‘path’ 不存在,将引发异常。
|
||||
|
||||
列:
|
||||
|
||||
- `name` (String) — The name of the node.
|
||||
- `path` (String) — The path to the node.
|
||||
- `value` (String) — Node value.
|
||||
- `dataLength` (Int32) — Size of the value.
|
||||
- `numChildren` (Int32) — Number of descendants.
|
||||
- `czxid` (Int64) — ID of the transaction that created the node.
|
||||
- `mzxid` (Int64) — ID of the transaction that last changed the node.
|
||||
- `pzxid` (Int64) — ID of the transaction that last deleted or added descendants.
|
||||
- `ctime` (DateTime) — Time of node creation.
|
||||
- `mtime` (DateTime) — Time of the last modification of the node.
|
||||
- `version` (Int32) — Node version: the number of times the node was changed.
|
||||
- `cversion` (Int32) — Number of added or removed descendants.
|
||||
- `aversion` (Int32) — Number of changes to the ACL.
|
||||
- `ephemeralOwner` (Int64) — For ephemeral nodes, the ID of the session that owns this node.
|
||||
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT *
|
||||
FROM system.zookeeper
|
||||
WHERE path = '/clickhouse/tables/01-08/visits/replicas'
|
||||
FORMAT Vertical
|
||||
```
|
||||
|
||||
``` text
|
||||
Row 1:
|
||||
──────
|
||||
name: example01-08-1.yandex.ru
|
||||
value:
|
||||
czxid: 932998691229
|
||||
mzxid: 932998691229
|
||||
ctime: 2015-03-27 16:49:51
|
||||
mtime: 2015-03-27 16:49:51
|
||||
version: 0
|
||||
cversion: 47
|
||||
aversion: 0
|
||||
ephemeralOwner: 0
|
||||
dataLength: 0
|
||||
numChildren: 7
|
||||
pzxid: 987021031383
|
||||
path: /clickhouse/tables/01-08/visits/replicas
|
||||
|
||||
Row 2:
|
||||
──────
|
||||
name: example01-08-2.yandex.ru
|
||||
value:
|
||||
czxid: 933002738135
|
||||
mzxid: 933002738135
|
||||
ctime: 2015-03-27 16:57:01
|
||||
mtime: 2015-03-27 16:57:01
|
||||
version: 0
|
||||
cversion: 37
|
||||
aversion: 0
|
||||
ephemeralOwner: 0
|
||||
dataLength: 0
|
||||
numChildren: 7
|
||||
pzxid: 987021252247
|
||||
path: /clickhouse/tables/01-08/visits/replicas
|
||||
```
|
@ -19,7 +19,7 @@ ClickHouse:
|
||||
|
||||
字典可以在服务器启动或首次使用时加载,具体取决于 [dictionaries\_lazy\_load](../../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-dictionaries_lazy_load) 设置。
|
||||
|
||||
该 [字典](../../../operations/system-tables.md#system_tables-dictionaries) 系统表包含有关在服务器上配置的字典的信息。 对于每个字典,你可以在那里找到:
|
||||
该 [字典](../../../operations/system-tables/dictionaries.md#system_tables-dictionaries) 系统表包含有关在服务器上配置的字典的信息。 对于每个字典,你可以在那里找到:
|
||||
|
||||
- 字典的状态。
|
||||
- 配置参数。
|
||||
|
@ -20,7 +20,7 @@ toc_title: "\u81EA\u7701"
|
||||
|
||||
For security reasons introspection functions are disabled by default.
|
||||
|
||||
ClickHouse将探查器报告保存到 [trace\_log](../../operations/system-tables.md#system_tables-trace_log) 系统表. 确保正确配置了表和探查器。
|
||||
ClickHouse将探查器报告保存到 [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log) 系统表. 确保正确配置了表和探查器。
|
||||
|
||||
## addressToLine {#addresstoline}
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
../../../en/sql-reference/operators/in.md
|
204
docs/zh/sql-reference/operators/in.md
Normal file
204
docs/zh/sql-reference/operators/in.md
Normal file
@ -0,0 +1,204 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
---
|
||||
|
||||
# 在运营商 {#select-in-operators}
|
||||
|
||||
该 `IN`, `NOT IN`, `GLOBAL IN`,和 `GLOBAL NOT IN` 运算符是单独复盖的,因为它们的功能相当丰富。
|
||||
|
||||
运算符的左侧是单列或元组。
|
||||
|
||||
例:
|
||||
|
||||
``` sql
|
||||
SELECT UserID IN (123, 456) FROM ...
|
||||
SELECT (CounterID, UserID) IN ((34, 123), (101500, 456)) FROM ...
|
||||
```
|
||||
|
||||
如果左侧是索引中的单列,而右侧是一组常量,则系统将使用索引处理查询。
|
||||
|
||||
Don't list too many values explicitly (i.e. millions). If a data set is large, put it in a temporary table (for example, see the section “External data for query processing”),然后使用子查询。
|
||||
|
||||
运算符的右侧可以是一组常量表达式、一组带有常量表达式的元组(如上面的示例所示),或括号中的数据库表或SELECT子查询的名称。
|
||||
|
||||
如果运算符的右侧是表的名称(例如, `UserID IN users`),这相当于子查询 `UserID IN (SELECT * FROM users)`. 使用与查询一起发送的外部数据时,请使用此选项。 例如,查询可以与一组用户Id一起发送到 ‘users’ 应过滤的临时表。
|
||||
|
||||
如果运算符的右侧是具有Set引擎的表名(始终位于RAM中的准备好的数据集),则不会为每个查询重新创建数据集。
|
||||
|
||||
子查询可以指定多个用于筛选元组的列。
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT (CounterID, UserID) IN (SELECT CounterID, UserID FROM ...) FROM ...
|
||||
```
|
||||
|
||||
IN运算符左侧和右侧的列应具有相同的类型。
|
||||
|
||||
IN运算符和子查询可能出现在查询的任何部分,包括聚合函数和lambda函数。
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
EventDate,
|
||||
avg(UserID IN
|
||||
(
|
||||
SELECT UserID
|
||||
FROM test.hits
|
||||
WHERE EventDate = toDate('2014-03-17')
|
||||
)) AS ratio
|
||||
FROM test.hits
|
||||
GROUP BY EventDate
|
||||
ORDER BY EventDate ASC
|
||||
```
|
||||
|
||||
``` text
|
||||
┌──EventDate─┬────ratio─┐
|
||||
│ 2014-03-17 │ 1 │
|
||||
│ 2014-03-18 │ 0.807696 │
|
||||
│ 2014-03-19 │ 0.755406 │
|
||||
│ 2014-03-20 │ 0.723218 │
|
||||
│ 2014-03-21 │ 0.697021 │
|
||||
│ 2014-03-22 │ 0.647851 │
|
||||
│ 2014-03-23 │ 0.648416 │
|
||||
└────────────┴──────────┘
|
||||
```
|
||||
|
||||
对于3月17日后的每一天,计算3月17日访问该网站的用户所做的浏览量百分比。
|
||||
IN子句中的子查询始终只在单个服务器上运行一次。 没有依赖子查询。
|
||||
|
||||
## 空处理 {#in-null-processing}
|
||||
|
||||
在请求处理过程中, `IN` 运算符假定运算的结果 [NULL](../../sql-reference/syntax.md#null-literal) 总是等于 `0`,无论是否 `NULL` 位于操作员的右侧或左侧。 `NULL` 值不包含在任何数据集中,彼此不对应,并且在以下情况下无法进行比较 [transform\_null\_in=0](../../operations/settings/settings.md#transform_null_in).
|
||||
|
||||
下面是一个例子 `t_null` 表:
|
||||
|
||||
``` text
|
||||
┌─x─┬────y─┐
|
||||
│ 1 │ ᴺᵁᴸᴸ │
|
||||
│ 2 │ 3 │
|
||||
└───┴──────┘
|
||||
```
|
||||
|
||||
运行查询 `SELECT x FROM t_null WHERE y IN (NULL,3)` 为您提供以下结果:
|
||||
|
||||
``` text
|
||||
┌─x─┐
|
||||
│ 2 │
|
||||
└───┘
|
||||
```
|
||||
|
||||
你可以看到,在其中的行 `y = NULL` 被抛出的查询结果。 这是因为ClickHouse无法决定是否 `NULL` 包含在 `(NULL,3)` 设置,返回 `0` 作为操作的结果,和 `SELECT` 从最终输出中排除此行。
|
||||
|
||||
``` sql
|
||||
SELECT y IN (NULL, 3)
|
||||
FROM t_null
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─in(y, tuple(NULL, 3))─┐
|
||||
│ 0 │
|
||||
│ 1 │
|
||||
└───────────────────────┘
|
||||
```
|
||||
|
||||
## 分布式子查询 {#select-distributed-subqueries}
|
||||
|
||||
带子查询的IN-s有两个选项(类似于连接):normal `IN` / `JOIN` 和 `GLOBAL IN` / `GLOBAL JOIN`. 它们在分布式查询处理的运行方式上有所不同。
|
||||
|
||||
!!! attention "注意"
|
||||
请记住,下面描述的算法可能会有不同的工作方式取决于 [设置](../../operations/settings/settings.md) `distributed_product_mode` 设置。
|
||||
|
||||
当使用常规IN时,查询被发送到远程服务器,并且它们中的每个服务器都在运行子查询 `IN` 或 `JOIN` 条款
|
||||
|
||||
使用时 `GLOBAL IN` / `GLOBAL JOINs`,首先所有的子查询都运行 `GLOBAL IN` / `GLOBAL JOINs`,并将结果收集在临时表中。 然后将临时表发送到每个远程服务器,其中使用此临时数据运行查询。
|
||||
|
||||
对于非分布式查询,请使用常规 `IN` / `JOIN`.
|
||||
|
||||
在使用子查询时要小心 `IN` / `JOIN` 用于分布式查询处理的子句。
|
||||
|
||||
让我们来看看一些例子。 假设集群中的每个服务器都有一个正常的 **local\_table**. 每个服务器还具有 **distributed\_table** 表与 **分布** 类型,它查看群集中的所有服务器。
|
||||
|
||||
对于查询 **distributed\_table**,查询将被发送到所有远程服务器,并使用以下命令在其上运行 **local\_table**.
|
||||
|
||||
例如,查询
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM distributed_table
|
||||
```
|
||||
|
||||
将被发送到所有远程服务器
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM local_table
|
||||
```
|
||||
|
||||
并且并行运行它们中的每一个,直到达到可以结合中间结果的阶段。 然后将中间结果返回给请求者服务器并在其上合并,并将最终结果发送给客户端。
|
||||
|
||||
现在让我们检查一个查询IN:
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34)
|
||||
```
|
||||
|
||||
- 计算两个网站的受众的交集。
|
||||
|
||||
此查询将以下列方式发送到所有远程服务器
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34)
|
||||
```
|
||||
|
||||
换句话说,IN子句中的数据集将在每台服务器上独立收集,仅在每台服务器上本地存储的数据中收集。
|
||||
|
||||
如果您已经为此情况做好准备,并且已经将数据分散到群集服务器上,以便单个用户Id的数据完全驻留在单个服务器上,则这将正常和最佳地工作。 在这种情况下,所有必要的数据将在每台服务器上本地提供。 否则,结果将是不准确的。 我们将查询的这种变体称为 “local IN”.
|
||||
|
||||
若要更正数据在群集服务器上随机传播时查询的工作方式,可以指定 **distributed\_table** 在子查询中。 查询如下所示:
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34)
|
||||
```
|
||||
|
||||
此查询将以下列方式发送到所有远程服务器
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34)
|
||||
```
|
||||
|
||||
子查询将开始在每个远程服务器上运行。 由于子查询使用分布式表,因此每个远程服务器上的子查询将重新发送到每个远程服务器
|
||||
|
||||
``` sql
|
||||
SELECT UserID FROM local_table WHERE CounterID = 34
|
||||
```
|
||||
|
||||
例如,如果您有100台服务器的集群,则执行整个查询将需要10,000个基本请求,这通常被认为是不可接受的。
|
||||
|
||||
在这种情况下,应始终使用GLOBAL IN而不是IN。 让我们来看看它是如何工作的查询
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID GLOBAL IN (SELECT UserID FROM distributed_table WHERE CounterID = 34)
|
||||
```
|
||||
|
||||
请求者服务器将运行子查询
|
||||
|
||||
``` sql
|
||||
SELECT UserID FROM distributed_table WHERE CounterID = 34
|
||||
```
|
||||
|
||||
结果将被放在RAM中的临时表中。 然后请求将被发送到每个远程服务器
|
||||
|
||||
``` sql
|
||||
SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID GLOBAL IN _data1
|
||||
```
|
||||
|
||||
和临时表 `_data1` 将通过查询发送到每个远程服务器(临时表的名称是实现定义的)。
|
||||
|
||||
这比使用正常IN更优化。 但是,请记住以下几点:
|
||||
|
||||
1. 创建临时表时,数据不是唯一的。 要减少通过网络传输的数据量,请在子查询中指定DISTINCT。 (你不需要为正常人做这个。)
|
||||
2. 临时表将被发送到所有远程服务器。 传输不考虑网络拓扑。 例如,如果10个远程服务器驻留在与请求者服务器非常远程的数据中心中,则数据将通过通道发送10次到远程数据中心。 使用GLOBAL IN时尽量避免使用大型数据集。
|
||||
3. 将数据传输到远程服务器时,无法配置网络带宽限制。 您可能会使网络过载。
|
||||
4. 尝试跨服务器分发数据,以便您不需要定期使用GLOBAL IN。
|
||||
5. 如果您需要经常使用GLOBAL IN,请规划ClickHouse集群的位置,以便单个副本组驻留在不超过一个数据中心中,并且它们之间具有快速网络,以便可以完全在单个数据中心内处理查询。
|
||||
|
||||
这也是有意义的,在指定一个本地表 `GLOBAL IN` 子句,以防此本地表仅在请求者服务器上可用,并且您希望在远程服务器上使用来自它的数据。
|
@ -113,7 +113,7 @@ MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [TTL]
|
||||
|
||||
- TTL
|
||||
|
||||
有关修改列TTL的示例,请参见 [Column TTL](../engines/table_engines/mergetree_family/mergetree.md#mergetree-column-ttl).
|
||||
有关修改列TTL的示例,请参见 [Column TTL](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-column-ttl).
|
||||
|
||||
如果语句中包含 `IF EXISTS` ,遇到不存在的列,sql执行不会报错。
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
../../../en/sql-reference/statements/grant.md
|
472
docs/zh/sql-reference/statements/grant.md
Normal file
472
docs/zh/sql-reference/statements/grant.md
Normal file
@ -0,0 +1,472 @@
|
||||
---
|
||||
toc_priority: 39
|
||||
toc_title: 授权操作
|
||||
---
|
||||
|
||||
# 授权 {#grant}
|
||||
- 给ClickHouse的用户或角色赋予 [权限](#grant-privileges)
|
||||
- 将角色分配给用户或其他角色
|
||||
|
||||
取消权限,使用 [REVOKE](../../sql-reference/statements/revoke.md)语句。查看已授权的权限请使用 [SHOW GRANTS](../../sql-reference/statements/show.md#show-grants-statement)。
|
||||
|
||||
## 授权操作语法 {#grant-privigele-syntax}
|
||||
|
||||
``` sql
|
||||
GRANT [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.table|db.*|*.*|table|*} TO {user | role | CURRENT_USER} [,...] [WITH GRANT OPTION]
|
||||
```
|
||||
|
||||
- `privilege` — 权限类型
|
||||
- `role` — 用户角色
|
||||
- `user` — 用户账号
|
||||
|
||||
`WITH GRANT OPTION` 授予 `user` 或 `role`执行 `GRANT` 操作的权限。用户可将在自身权限范围内的权限进行授权
|
||||
|
||||
## 角色分配的语法 {#assign-role-syntax}
|
||||
|
||||
``` sql
|
||||
GRANT [ON CLUSTER cluster_name] role [,...] TO {user | another_role | CURRENT_USER} [,...] [WITH ADMIN OPTION]
|
||||
```
|
||||
|
||||
- `role` — 角色
|
||||
- `user` — 用户
|
||||
|
||||
`WITH ADMIN OPTION` 授予 `user` 或 `role` 执行[ADMIN OPTION](#admin-option-privilege) 的权限
|
||||
|
||||
## 用法 {#grant-usage}
|
||||
|
||||
使用 `GRANT`,你的账号必须有 `GRANT OPTION`的权限。用户只能将在自身权限范围内的权限进行授权
|
||||
|
||||
例如,管理员有权通过下面的语句给 `john`账号添加授权
|
||||
|
||||
``` sql
|
||||
GRANT SELECT(x,y) ON db.table TO john WITH GRANT OPTION
|
||||
```
|
||||
|
||||
这意味着 `john` 有权限执行以下操作:
|
||||
|
||||
- `SELECT x,y FROM db.table`.
|
||||
- `SELECT x FROM db.table`.
|
||||
- `SELECT y FROM db.table`.
|
||||
|
||||
`john` 不能执行`SELECT z FROM db.table`。同样的 `SELECT * FROMdb.table` 也是不允许的。执行这个查询时,CH不会返回任何数据,甚至 `x` 和 `y`列。唯一的例外是,当表仅包含 `x`和`y`列时。这种情况下,CH返回所有数据。
|
||||
|
||||
同样 `john` 有权执行 `GRANT OPTION`,因此他能给其它账号进行和自己账号权限范围相同的授权。
|
||||
|
||||
可以使用`*` 号代替表或库名进行授权操作。例如, `GRANT SELECT ONdb.* TO john` 操作运行 `john`对 `db`库的所有表执行 `SELECT`查询。同样,你可以忽略库名。在这种情形下,权限将指向当前的数据库。例如, `GRANT SELECT ON* to john` 对当前数据库的所有表指定授权, `GARNT SELECT ON mytable to john`对当前数据库的 `mytable`表进行授权。
|
||||
|
||||
访问 `systen`数据库总是被允许的(因为这个数据库用来处理sql操作)
|
||||
可以一次给多个账号进行多种授权操作。 `GRANT SELECT,INSERT ON *.* TO john,robin` 允许 `john`和`robin` 账号对任意数据库的任意表执行 `INSERT`和 `SELECT`操作。
|
||||
|
||||
## 权限 {#grant-privileges}
|
||||
|
||||
权限是指执行特定操作的许可
|
||||
|
||||
权限有层级结构。一组允许的操作依赖相应的权限范围。
|
||||
|
||||
权限的层级:
|
||||
|
||||
- [SELECT](#grant-select)
|
||||
- [INSERT](#grant-insert)
|
||||
- [ALTER](#grant-alter)
|
||||
- `ALTER TABLE`
|
||||
- `ALTER UPDATE`
|
||||
- `ALTER DELETE`
|
||||
- `ALTER COLUMN`
|
||||
- `ALTER ADD COLUMN`
|
||||
- `ALTER DROP COLUMN`
|
||||
- `ALTER MODIFY COLUMN`
|
||||
- `ALTER COMMENT COLUMN`
|
||||
- `ALTER CLEAR COLUMN`
|
||||
- `ALTER RENAME COLUMN`
|
||||
- `ALTER INDEX`
|
||||
- `ALTER ORDER BY`
|
||||
- `ALTER ADD INDEX`
|
||||
- `ALTER DROP INDEX`
|
||||
- `ALTER MATERIALIZE INDEX`
|
||||
- `ALTER CLEAR INDEX`
|
||||
- `ALTER CONSTRAINT`
|
||||
- `ALTER ADD CONSTRAINT`
|
||||
|
||||
- `ALTER DROP CONSTRAINT`
|
||||
- `ALTER TTL`
|
||||
- `ALTER MATERIALIZE TTL`
|
||||
- `ALTER SETTINGS`
|
||||
- `ALTER MOVE PARTITION`
|
||||
- `ALTER FETCH PARTITION`
|
||||
- `ALTER FREEZE PARTITION`
|
||||
- `ALTER VIEW`
|
||||
- `ALTER VIEW REFRESH`
|
||||
- `ALTER VIEW MODIFY QUERY`
|
||||
- [CREATE](#grant-create)
|
||||
- `CREATE DATABASE`
|
||||
- `CREATE TABLE`
|
||||
- `CREATE VIEW`
|
||||
- `CREATE DICTIONARY`
|
||||
- `CREATE TEMPORARY TABLE`
|
||||
- [DROP](#grant-drop)
|
||||
- `DROP DATABASE`
|
||||
- `DROP TABLE`
|
||||
- `DROP VIEW`
|
||||
- `DROP DICTIONARY`
|
||||
- [TRUNCATE](#grant-truncate)
|
||||
- [OPTIMIZE](#grant-optimize)
|
||||
- [SHOW](#grant-show)
|
||||
- `SHOW DATABASES`
|
||||
- `SHOW TABLES`
|
||||
- `SHOW COLUMNS`
|
||||
- `SHOW DICTIONARIES`
|
||||
- [KILL QUERY](#grant-kill-query)
|
||||
- [ACCESS MANAGEMENT](#grant-access-management)
|
||||
- `CREATE USER`
|
||||
- `ALTER USER`
|
||||
- `DROP USER`
|
||||
- `CREATE ROLE`
|
||||
- `ALTER ROLE`
|
||||
- `DROP ROLE`
|
||||
- `CREATE ROW POLICY`
|
||||
- `ALTER ROW POLICY`
|
||||
- `DROP ROW POLICY`
|
||||
- `CREATE QUOTA`
|
||||
- `ALTER QUOTA`
|
||||
- `DROP QUOTA`
|
||||
- `CREATE SETTINGS PROFILE`
|
||||
- `ALTER SETTINGS PROFILE`
|
||||
- `DROP SETTINGS PROFILE`
|
||||
- `SHOW ACCESS`
|
||||
- `SHOW_USERS`
|
||||
- `SHOW_ROLES`
|
||||
- `SHOW_ROW_POLICIES`
|
||||
- `SHOW_QUOTAS`
|
||||
- `SHOW_SETTINGS_PROFILES`
|
||||
- `ROLE ADMIN`
|
||||
- [SYSTEM](#grant-system)
|
||||
- `SYSTEM SHUTDOWN`
|
||||
- `SYSTEM DROP CACHE`
|
||||
- `SYSTEM DROP DNS CACHE`
|
||||
- `SYSTEM DROP MARK CACHE`
|
||||
- `SYSTEM DROP UNCOMPRESSED CACHE`
|
||||
- `SYSTEM RELOAD`
|
||||
- `SYSTEM RELOAD CONFIG`
|
||||
- `SYSTEM RELOAD DICTIONARY`
|
||||
- `SYSTEM RELOAD EMBEDDED DICTIONARIES`
|
||||
- `SYSTEM MERGES`
|
||||
- `SYSTEM TTL MERGES`
|
||||
- `SYSTEM FETCHES`
|
||||
- `SYSTEM MOVES`
|
||||
- `SYSTEM SENDS`
|
||||
- `SYSTEM DISTRIBUTED SENDS`
|
||||
- `SYSTEM REPLICATED SENDS`
|
||||
- `SYSTEM REPLICATION QUEUES`
|
||||
- `SYSTEM SYNC REPLICA`
|
||||
- `SYSTEM RESTART REPLICA`
|
||||
- `SYSTEM FLUSH`
|
||||
- `SYSTEM FLUSH DISTRIBUTED`
|
||||
- `SYSTEM FLUSH LOGS`
|
||||
- [INTROSPECTION](#grant-introspection)
|
||||
- `addressToLine`
|
||||
- `addressToSymbol`
|
||||
- `demangle`
|
||||
- [SOURCES](#grant-sources)
|
||||
- `FILE`
|
||||
- `URL`
|
||||
- `REMOTE`
|
||||
- `YSQL`
|
||||
- `ODBC`
|
||||
- `JDBC`
|
||||
- `HDFS`
|
||||
- `S3`
|
||||
- [dictGet](#grant-dictget)
|
||||
|
||||
如何对待该层级的示例:
|
||||
- `ALTER` 权限包含所有其它 `ALTER *` 的权限
|
||||
- `ALTER CONSTRAINT` 包含 `ALTER ADD CONSTRAINT` 和 `ALTER DROP CONSTRAINT`权限
|
||||
|
||||
权限被应用到不同级别。 Knowing of a level suggests syntax available for privilege.
|
||||
|
||||
级别(由低到高):
|
||||
|
||||
- `COLUMN` - 可以授权到列,表,库或者全局
|
||||
- `TABLE` - 可以授权到表,库,或全局
|
||||
- `VIEW` - 可以授权到视图,库,或全局
|
||||
- `DICTIONARY` - 可以授权到字典,库,或全局
|
||||
- `DATABASE` - 可以授权到数据库或全局
|
||||
- `GLABLE` - 可以授权到全局
|
||||
- `GROUP` - 不同级别的权限分组。当授予 `GROUP`级别的权限时, 根据所用的语法,只有对应分组中的权限才会被分配。
|
||||
|
||||
允许的语法示例:
|
||||
|
||||
- `GRANT SELECT(x) ON db.table TO user`
|
||||
- `GRANT SELECT ON db.* TO user`
|
||||
|
||||
不允许的语法示例:
|
||||
|
||||
- `GRANT CREATE USER(x) ON db.table TO user`
|
||||
- `GRANT CREATE USER ON db.* TO user`
|
||||
|
||||
特殊的权限 `ALL` 将所有权限授予给用户或角色
|
||||
|
||||
默认情况下,一个用户账号或角色没有可授予的权限
|
||||
|
||||
如果用户或角色没有任何权限,它将显示为 `NONE`权限
|
||||
|
||||
有些操作根据它们的实现需要一系列的权限。例如, [RENAME](../../sql-reference/statements/misc.md#misc_operations-rename)操作需要以下权限来执行:`SELECT`, `CREATE TABLE`, `INSERT` 和 `DROP TABLE`。
|
||||
|
||||
### SELECT {#grant-select}
|
||||
|
||||
允许执行 [SELECT](../../sql-reference/statements/select/index.md) 查询
|
||||
|
||||
权限级别: `COLUMN`.
|
||||
|
||||
**说明**
|
||||
|
||||
有该权限的用户可以对指定的表和库的指定列进行 `SELECT`查询。如果用户查询包含了其它列则结果不返回数据。
|
||||
|
||||
考虑如下的授权语句:
|
||||
|
||||
``` sql
|
||||
GRANT SELECT(x,y) ON db.table TO john
|
||||
```
|
||||
|
||||
该权限允许 `john` 对 `db.table`表的列`x`,`y`执行任意 `SELECT `查询,例如 `SELECT x FROM db.table`。 `john` 不能执行 `SELECT z FROM db.table`以及 `SELECT * FROM db.table`。执行这个查询时,CH不会返回任何数据,甚至 `x` 和 `y`列。唯一的例外是,当表仅包含 `x`和`y`列时。这种情况下,CH返回所有数据。
|
||||
|
||||
### INSERT {#grant-insert}
|
||||
|
||||
允许执行 [INSERT](../../sql-reference/statements/insert-into.md) 操作.
|
||||
|
||||
权限级别: `COLUMN`.
|
||||
|
||||
**说明**
|
||||
|
||||
有该权限的用户可以对指定的表和库的指定列进行 `INSERT`操作。如果用户查询包含了其它列则结果不返回数据。
|
||||
|
||||
**示例**
|
||||
|
||||
``` sql
|
||||
GRANT INSERT(x,y) ON db.table TO john
|
||||
```
|
||||
|
||||
该权限允许 `john` 对 `db.table`表的列`x`,`y`执行数据插入操作
|
||||
|
||||
### ALTER {#grant-alter}
|
||||
|
||||
允许根据下列权限层级执行 [ALTER](../../sql-reference/statements/alter.md)操作
|
||||
|
||||
- `ALTER`. 级别: `COLUMN`.
|
||||
- `ALTER TABLE`. 级别: `GROUP`
|
||||
- `ALTER UPDATE`. 级别: `COLUMN`. 别名: `UPDATE`
|
||||
- `ALTER DELETE`. 级别: `COLUMN`. 别名: `DELETE`
|
||||
- `ALTER COLUMN`. 级别: `GROUP`
|
||||
- `ALTER ADD COLUMN`. 级别: `COLUMN`. 别名: `ADD COLUMN`
|
||||
- `ALTER DROP COLUMN`. 级别: `COLUMN`. 别名: `DROP COLUMN`
|
||||
- `ALTER MODIFY COLUMN`. 级别: `COLUMN`. 别名: `MODIFY COLUMN`
|
||||
- `ALTER COMMENT COLUMN`. 级别: `COLUMN`. 别名: `COMMENT COLUMN`
|
||||
- `ALTER CLEAR COLUMN`. 级别: `COLUMN`. 别名: `CLEAR COLUMN`
|
||||
- `ALTER RENAME COLUMN`. 级别: `COLUMN`. 别名: `RENAME COLUMN`
|
||||
- `ALTER INDEX`. 级别: `GROUP`. 别名: `INDEX`
|
||||
- `ALTER ORDER BY`. 级别: `TABLE`. 别名: `ALTER MODIFY ORDER BY`, `MODIFY ORDER BY`
|
||||
- `ALTER ADD INDEX`. 级别: `TABLE`. 别名: `ADD INDEX`
|
||||
- `ALTER DROP INDEX`. 级别: `TABLE`. 别名: `DROP INDEX`
|
||||
- `ALTER MATERIALIZE INDEX`. 级别: `TABLE`. 别名: `MATERIALIZE INDEX`
|
||||
- `ALTER CLEAR INDEX`. 级别: `TABLE`. 别名: `CLEAR INDEX`
|
||||
- `ALTER CONSTRAINT`. 级别: `GROUP`. 别名: `CONSTRAINT`
|
||||
- `ALTER ADD CONSTRAINT`. 级别: `TABLE`. 别名: `ADD CONSTRAINT`
|
||||
- `ALTER DROP CONSTRAINT`. 级别: `TABLE`. 别名: `DROP CONSTRAINT`
|
||||
- `ALTER TTL`. 级别: `TABLE`. 别名: `ALTER MODIFY TTL`, `MODIFY TTL`
|
||||
- `ALTER MATERIALIZE TTL`. 级别: `TABLE`. 别名: `MATERIALIZE TTL`
|
||||
- `ALTER SETTINGS`. 级别: `TABLE`. 别名: `ALTER SETTING`, `ALTER MODIFY SETTING`, `MODIFY SETTING`
|
||||
- `ALTER MOVE PARTITION`. 级别: `TABLE`. 别名: `ALTER MOVE PART`, `MOVE PARTITION`, `MOVE PART`
|
||||
- `ALTER FETCH PARTITION`. 级别: `TABLE`. 别名: `FETCH PARTITION`
|
||||
- `ALTER FREEZE PARTITION`. 级别: `TABLE`. 别名: `FREEZE PARTITION`
|
||||
- `ALTER VIEW` 级别: `GROUP`
|
||||
- `ALTER VIEW REFRESH`. 级别: `VIEW`. 别名: `ALTER LIVE VIEW REFRESH`, `REFRESH VIEW`
|
||||
- `ALTER VIEW MODIFY QUERY`. 级别: `VIEW`. 别名: `ALTER TABLE MODIFY QUERY`
|
||||
|
||||
如何对待该层级的示例:
|
||||
- `ALTER` 权限包含所有其它 `ALTER *` 的权限
|
||||
- `ALTER CONSTRAINT` 包含 `ALTER ADD CONSTRAINT` 和 `ALTER DROP CONSTRAINT`权限
|
||||
|
||||
**备注**
|
||||
|
||||
- `MODIFY SETTING`权限允许修改表的引擎设置。它不会影响服务的配置参数
|
||||
- `ATTACH` 操作需要 [CREATE](#grant-create) 权限.
|
||||
- `DETACH` 操作需要 [DROP](#grant-drop) 权限.
|
||||
- 要通过 [KILL MUTATION](../../sql-reference/statements/misc.md#kill-mutation) 操作来终止mutation, 你需要有发起mutation操作的权限。例如,当你想终止 `ALTER UPDATE`操作时,需要有 `ALTER UPDATE`, `ALTER TABLE`, 或 `ALTER`权限
|
||||
|
||||
### CREATE {#grant-create}
|
||||
|
||||
允许根据下面的权限层级来执行 [CREATE](../../sql-reference/statements/create.md) 和 [ATTACH](../../sql-reference/statements/misc.md#attach) DDL语句:
|
||||
|
||||
- `CREATE`. 级别: `GROUP`
|
||||
- `CREATE DATABASE`. 级别: `DATABASE`
|
||||
- `CREATE TABLE`. 级别: `TABLE`
|
||||
- `CREATE VIEW`. 级别: `VIEW`
|
||||
- `CREATE DICTIONARY`. 级别: `DICTIONARY`
|
||||
- `CREATE TEMPORARY TABLE`. 级别: `GLOBAL`
|
||||
|
||||
**备注**
|
||||
|
||||
- 删除已创建的表,用户需要 [DROP](#grant-drop)权限
|
||||
|
||||
### DROP {#grant-drop}
|
||||
|
||||
允许根据下面的权限层级来执行 [DROP](../../sql-reference/statements/misc.md#drop) 和 [DETACH](../../sql-reference/statements/misc.md#detach) :
|
||||
|
||||
- `DROP`. 级别:
|
||||
- `DROP DATABASE`. 级别: `DATABASE`
|
||||
- `DROP TABLE`. 级别: `TABLE`
|
||||
- `DROP VIEW`. 级别: `VIEW`
|
||||
- `DROP DICTIONARY`. 级别: `DICTIONARY`
|
||||
|
||||
### TRUNCATE {#grant-truncate}
|
||||
|
||||
允许执行 [TRUNCATE](../../sql-reference/statements/misc.md#truncate-statement) .
|
||||
|
||||
权限级别: `TABLE`.
|
||||
|
||||
### OPTIMIZE {#grant-optimize}
|
||||
|
||||
允许执行 [OPTIMIZE TABLE](../../sql-reference/statements/misc.md#misc_operations-optimize) .
|
||||
|
||||
权限级别: `TABLE`.
|
||||
|
||||
### SHOW {#grant-show}
|
||||
|
||||
允许根据下面的权限层级来执行 `SHOW`, `DESCRIBE`, `USE`, 和 `EXISTS` :
|
||||
|
||||
- `SHOW`. 级别: `GROUP`
|
||||
- `SHOW DATABASES`. 级别: `DATABASE`. 允许执行 `SHOW DATABASES`, `SHOW CREATE DATABASE`, `USE <database>` .
|
||||
- `SHOW TABLES`. 级别: `TABLE`. 允许执行 `SHOW TABLES`, `EXISTS <table>`, `CHECK <table>` .
|
||||
- `SHOW COLUMNS`. 级别: `COLUMN`. 允许执行 `SHOW CREATE TABLE`, `DESCRIBE` .
|
||||
- `SHOW DICTIONARIES`. 级别: `DICTIONARY`. 允许执行 `SHOW DICTIONARIES`, `SHOW CREATE DICTIONARY`, `EXISTS <dictionary>` .
|
||||
|
||||
**备注**
|
||||
|
||||
用户同时拥有 `SHOW`权限,当用户对指定表,字典或数据库有其它的权限时。
|
||||
|
||||
### KILL QUERY {#grant-kill-query}
|
||||
|
||||
允许根据下面的权限层级来执行 [KILL](../../sql-reference/statements/misc.md#kill-query-statement):
|
||||
|
||||
权限级别: `GLOBAL`.
|
||||
|
||||
**备注**
|
||||
|
||||
`KILL QUERY` 权限允许用户终止其它用户提交的操作。
|
||||
|
||||
### 访问管理 {#grant-access-management}
|
||||
|
||||
允许用户执行管理用户/角色和行规则的操作:
|
||||
|
||||
- `ACCESS MANAGEMENT`. 级别: `GROUP`
|
||||
- `CREATE USER`. 级别: `GLOBAL`
|
||||
- `ALTER USER`. 级别: `GLOBAL`
|
||||
- `DROP USER`. 级别: `GLOBAL`
|
||||
- `CREATE ROLE`. 级别: `GLOBAL`
|
||||
- `ALTER ROLE`. 级别: `GLOBAL`
|
||||
- `DROP ROLE`. 级别: `GLOBAL`
|
||||
- `ROLE ADMIN`. 级别: `GLOBAL`
|
||||
- `CREATE ROW POLICY`. 级别: `GLOBAL`. 别名: `CREATE POLICY`
|
||||
- `ALTER ROW POLICY`. 级别: `GLOBAL`. 别名: `ALTER POLICY`
|
||||
- `DROP ROW POLICY`. 级别: `GLOBAL`. 别名: `DROP POLICY`
|
||||
- `CREATE QUOTA`. 级别: `GLOBAL`
|
||||
- `ALTER QUOTA`. 级别: `GLOBAL`
|
||||
- `DROP QUOTA`. 级别: `GLOBAL`
|
||||
- `CREATE SETTINGS PROFILE`. 级别: `GLOBAL`. 别名: `CREATE PROFILE`
|
||||
- `ALTER SETTINGS PROFILE`. 级别: `GLOBAL`. 别名: `ALTER PROFILE`
|
||||
- `DROP SETTINGS PROFILE`. 级别: `GLOBAL`. 别名: `DROP PROFILE`
|
||||
- `SHOW ACCESS`. 级别: `GROUP`
|
||||
- `SHOW_USERS`. 级别: `GLOBAL`. 别名: `SHOW CREATE USER`
|
||||
- `SHOW_ROLES`. 级别: `GLOBAL`. 别名: `SHOW CREATE ROLE`
|
||||
- `SHOW_ROW_POLICIES`. 级别: `GLOBAL`. 别名: `SHOW POLICIES`, `SHOW CREATE ROW POLICY`, `SHOW CREATE POLICY`
|
||||
- `SHOW_QUOTAS`. 级别: `GLOBAL`. 别名: `SHOW CREATE QUOTA`
|
||||
- `SHOW_SETTINGS_PROFILES`. 级别: `GLOBAL`. 别名: `SHOW PROFILES`, `SHOW CREATE SETTINGS PROFILE`, `SHOW CREATE PROFILE`
|
||||
|
||||
`ROLE ADMIN` 权限允许用户对角色进行分配以及撤回,包括根据管理选项尚未分配的角色
|
||||
|
||||
### SYSTEM {#grant-system}
|
||||
|
||||
允许根据下面的权限层级来执行 [SYSTEM](../../sql-reference/statements/system.md) :
|
||||
|
||||
- `SYSTEM`. 级别: `GROUP`
|
||||
- `SYSTEM SHUTDOWN`. 级别: `GLOBAL`. 别名: `SYSTEM KILL`, `SHUTDOWN`
|
||||
- `SYSTEM DROP CACHE`. 别名: `DROP CACHE`
|
||||
- `SYSTEM DROP DNS CACHE`. 级别: `GLOBAL`. 别名: `SYSTEM DROP DNS`, `DROP DNS CACHE`, `DROP DNS`
|
||||
- `SYSTEM DROP MARK CACHE`. 级别: `GLOBAL`. 别名: `SYSTEM DROP MARK`, `DROP MARK CACHE`, `DROP MARKS`
|
||||
- `SYSTEM DROP UNCOMPRESSED CACHE`. 级别: `GLOBAL`. 别名: `SYSTEM DROP UNCOMPRESSED`, `DROP UNCOMPRESSED CACHE`, `DROP UNCOMPRESSED`
|
||||
- `SYSTEM RELOAD`. 级别: `GROUP`
|
||||
- `SYSTEM RELOAD CONFIG`. 级别: `GLOBAL`. 别名: `RELOAD CONFIG`
|
||||
- `SYSTEM RELOAD DICTIONARY`. 级别: `GLOBAL`. 别名: `SYSTEM RELOAD DICTIONARIES`, `RELOAD DICTIONARY`, `RELOAD DICTIONARIES`
|
||||
- `SYSTEM RELOAD EMBEDDED DICTIONARIES`. 级别: `GLOBAL`. 别名: R`ELOAD EMBEDDED DICTIONARIES`
|
||||
- `SYSTEM MERGES`. 级别: `TABLE`. 别名: `SYSTEM STOP MERGES`, `SYSTEM START MERGES`, `STOP MERGES`, `START MERGES`
|
||||
- `SYSTEM TTL MERGES`. 级别: `TABLE`. 别名: `SYSTEM STOP TTL MERGES`, `SYSTEM START TTL MERGES`, `STOP TTL MERGES`, `START TTL MERGES`
|
||||
- `SYSTEM FETCHES`. 级别: `TABLE`. 别名: `SYSTEM STOP FETCHES`, `SYSTEM START FETCHES`, `STOP FETCHES`, `START FETCHES`
|
||||
- `SYSTEM MOVES`. 级别: `TABLE`. 别名: `SYSTEM STOP MOVES`, `SYSTEM START MOVES`, `STOP MOVES`, `START MOVES`
|
||||
- `SYSTEM SENDS`. 级别: `GROUP`. 别名: `SYSTEM STOP SENDS`, `SYSTEM START SENDS`, `STOP SENDS`, `START SENDS`
|
||||
- `SYSTEM DISTRIBUTED SENDS`. 级别: `TABLE`. 别名: `SYSTEM STOP DISTRIBUTED SENDS`, `SYSTEM START DISTRIBUTED SENDS`, `STOP DISTRIBUTED SENDS`, `START DISTRIBUTED SENDS`
|
||||
- `SYSTEM REPLICATED SENDS`. 级别: `TABLE`. 别名: `SYSTEM STOP REPLICATED SENDS`, `SYSTEM START REPLICATED SENDS`, `STOP REPLICATED SENDS`, `START REPLICATED SENDS`
|
||||
- `SYSTEM REPLICATION QUEUES`. 级别: `TABLE`. 别名: `SYSTEM STOP REPLICATION QUEUES`, `SYSTEM START REPLICATION QUEUES`, `STOP REPLICATION QUEUES`, `START REPLICATION QUEUES`
|
||||
- `SYSTEM SYNC REPLICA`. 级别: `TABLE`. 别名: `SYNC REPLICA`
|
||||
- `SYSTEM RESTART REPLICA`. 级别: `TABLE`. 别名: `RESTART REPLICA`
|
||||
- `SYSTEM FLUSH`. 级别: `GROUP`
|
||||
- `SYSTEM FLUSH DISTRIBUTED`. 级别: `TABLE`. 别名: `FLUSH DISTRIBUTED`
|
||||
- `SYSTEM FLUSH LOGS`. 级别: `GLOBAL`. 别名: `FLUSH LOGS`
|
||||
|
||||
|
||||
`SYSTEM RELOAD EMBEDDED DICTIONARIES` 权限隐式的通过操作 `SYSTEM RELOAD DICTIONARY ON *.*` 来进行授权.
|
||||
|
||||
### 内省introspection {#grant-introspection}
|
||||
|
||||
允许使用 [introspection](../../operations/optimizing-performance/sampling-query-profiler.md) 函数.
|
||||
|
||||
- `INTROSPECTION`. 级别: `GROUP`. 别名: `INTROSPECTION FUNCTIONS`
|
||||
- `addressToLine`. 级别: `GLOBAL`
|
||||
- `addressToSymbol`. 级别: `GLOBAL`
|
||||
- `demangle`. 级别: `GLOBAL`
|
||||
|
||||
### 数据源 {#grant-sources}
|
||||
|
||||
允许在 [table engines](../../engines/table-engines/index.md) 和 [table functions](../../sql-reference/table-functions/index.md#table-functions)中使用外部数据源。
|
||||
|
||||
- `SOURCES`. 级别: `GROUP`
|
||||
- `FILE`. 级别: `GLOBAL`
|
||||
- `URL`. 级别: `GLOBAL`
|
||||
- `REMOTE`. 级别: `GLOBAL`
|
||||
- `YSQL`. 级别: `GLOBAL`
|
||||
- `ODBC`. 级别: `GLOBAL`
|
||||
- `JDBC`. 级别: `GLOBAL`
|
||||
- `HDFS`. 级别: `GLOBAL`
|
||||
- `S3`. 级别: `GLOBAL`
|
||||
|
||||
`SOURCES` 权限允许使用所有数据源。当然也可以单独对每个数据源进行授权。要使用数据源时,还需要额外的权限。
|
||||
|
||||
示例:
|
||||
|
||||
- 创建 [MySQL table engine](../../engines/table-engines/integrations/mysql.md), 需要 `CREATE TABLE (ON db.table_name)` 和 `MYSQL`权限。4
|
||||
- 要使用 [mysql table function](../../sql-reference/table-functions/mysql.md),需要 `CREATE TEMPORARY TABLE` 和 `MYSQL` 权限
|
||||
|
||||
### dictGet {#grant-dictget}
|
||||
|
||||
- `dictGet`. 别名: `dictHas`, `dictGetHierarchy`, `dictIsIn`
|
||||
|
||||
允许用户执行 [dictGet](../../sql-reference/functions/ext-dict-functions.md#dictget), [dictHas](../../sql-reference/functions/ext-dict-functions.md#dicthas), [dictGetHierarchy](../../sql-reference/functions/ext-dict-functions.md#dictgethierarchy), [dictIsIn](../../sql-reference/functions/ext-dict-functions.md#dictisin) 等函数.
|
||||
|
||||
权限级别: `DICTIONARY`.
|
||||
|
||||
**示例**
|
||||
|
||||
- `GRANT dictGet ON mydb.mydictionary TO john`
|
||||
- `GRANT dictGet ON mydictionary TO john`
|
||||
|
||||
### ALL {#grant-all}
|
||||
|
||||
对规定的实体(列,表,库等)给用户或角色授予所有权限
|
||||
|
||||
### NONE {#grant-none}
|
||||
|
||||
不授予任何权限
|
||||
|
||||
### ADMIN OPTION {#admin-option-privilege}
|
||||
|
||||
`ADMIN OPTION` 权限允许用户将他们的角色分配给其它用户
|
||||
|
||||
[原始文档](https://clickhouse.tech/docs/en/query_language/grant/) <!--hide-->
|
@ -223,7 +223,7 @@ KILL MUTATION [ON CLUSTER cluster]
|
||||
[FORMAT format]
|
||||
```
|
||||
|
||||
尝试取消和删除 [突变](alter.md#alter-mutations) 当前正在执行。 要取消的突变选自 [`system.mutations`](../../operations/system-tables.md#system_tables-mutations) 表使用由指定的过滤器 `WHERE` 《公约》条款 `KILL` 查询。
|
||||
尝试取消和删除 [突变](alter.md#alter-mutations) 当前正在执行。 要取消的突变选自 [`system.mutations`](../../operations/system-tables/mutations.md#system_tables-mutations) 表使用由指定的过滤器 `WHERE` 《公约》条款 `KILL` 查询。
|
||||
|
||||
测试查询 (`TEST`)仅检查用户的权限并显示要停止的查询列表。
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
../../../en/sql-reference/statements/revoke.md
|
48
docs/zh/sql-reference/statements/revoke.md
Normal file
48
docs/zh/sql-reference/statements/revoke.md
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
toc_priority: 40
|
||||
toc_title: REVOKE
|
||||
---
|
||||
|
||||
# 权限取消 {#revoke}
|
||||
|
||||
取消用户或角色的权限
|
||||
|
||||
## 语法 {#revoke-语法}
|
||||
|
||||
**取消用户的权限**
|
||||
|
||||
``` sql
|
||||
REVOKE [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.table|db.*|*.*|table|*} FROM {user | CURRENT_USER} [,...] | ALL | ALL EXCEPT {user | CURRENT_USER} [,...]
|
||||
```
|
||||
|
||||
**取消用户的角色**
|
||||
|
||||
``` sql
|
||||
REVOKE [ON CLUSTER cluster_name] [ADMIN OPTION FOR] role [,...] FROM {user | role | CURRENT_USER} [,...] | ALL | ALL EXCEPT {user_name | role_name | CURRENT_USER} [,...]
|
||||
```
|
||||
|
||||
## 说明 {#revoke-description}
|
||||
|
||||
要取消某些权限,可使用比要撤回的权限更大范围的权限。例如,当用户有 `SELECT (x,y)`权限时,管理员可执行 `REVOKE SELECT(x,y) ...`, 或 `REVOKE SELECT * ...`, 甚至是 `REVOKE ALL PRIVILEGES ...`来取消原有权限。
|
||||
|
||||
### 取消部分权限 {#partial-revokes-dscr}
|
||||
|
||||
可以取消部分权限。例如,当用户有 `SELECT *.*` 权限时,可以通过授予对部分库或表的读取权限来撤回原有权限。
|
||||
|
||||
## 示例 {#revoke-example}
|
||||
|
||||
授权 `john`账号能查询所有库的所有表,除了 `account`库。
|
||||
|
||||
``` sql
|
||||
GRANT SELECT ON *.* TO john;
|
||||
REVOKE SELECT ON accounts.* FROM john;
|
||||
```
|
||||
|
||||
授权 `mira`账号能查询 `accounts.staff`表的所有列,除了 `wage`这一列。
|
||||
|
||||
``` sql
|
||||
GRANT SELECT ON accounts.staff TO mira;
|
||||
REVOKE SELECT(wage) ON accounts.staff FROM mira;
|
||||
```
|
||||
|
||||
{## [原始文档](https://clickhouse.tech/docs/en/operations/settings/settings/) ##}
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/array-join.md
|
283
docs/zh/sql-reference/statements/select/array-join.md
Normal file
283
docs/zh/sql-reference/statements/select/array-join.md
Normal file
@ -0,0 +1,283 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: ARRAY JOIN
|
||||
---
|
||||
|
||||
# ARRAY JOIN子句 {#select-array-join-clause}
|
||||
|
||||
对于包含数组列的表来说,这是一种常见的操作,用于生成一个新表,该表具有包含该初始列的每个单独数组元素的列,而其他列的值将被重复。 这是什么基本情况 `ARRAY JOIN` 子句有
|
||||
|
||||
它的名字来自这样一个事实,即它可以被视为执行 `JOIN` 具有数组或嵌套数据结构。 意图类似于 [arrayJoin](../../../sql-reference/functions/array-join.md#functions_arrayjoin) 功能,但该子句功能更广泛。
|
||||
|
||||
语法:
|
||||
|
||||
``` sql
|
||||
SELECT <expr_list>
|
||||
FROM <left_subquery>
|
||||
[LEFT] ARRAY JOIN <array>
|
||||
[WHERE|PREWHERE <expr>]
|
||||
...
|
||||
```
|
||||
|
||||
您只能指定一个 `ARRAY JOIN` a中的条款 `SELECT` 查询。
|
||||
|
||||
支持的类型 `ARRAY JOIN` 下面列出:
|
||||
|
||||
- `ARRAY JOIN` -在基本情况下,空数组不包括在结果中 `JOIN`.
|
||||
- `LEFT ARRAY JOIN` -的结果 `JOIN` 包含具有空数组的行。 空数组的值设置为数组元素类型的默认值(通常为0、空字符串或NULL)。
|
||||
|
||||
## 基本数组连接示例 {#basic-array-join-examples}
|
||||
|
||||
下面的例子演示的用法 `ARRAY JOIN` 和 `LEFT ARRAY JOIN` 条款 让我们创建一个表 [阵列](../../../sql-reference/data-types/array.md) 键入column并在其中插入值:
|
||||
|
||||
``` sql
|
||||
CREATE TABLE arrays_test
|
||||
(
|
||||
s String,
|
||||
arr Array(UInt8)
|
||||
) ENGINE = Memory;
|
||||
|
||||
INSERT INTO arrays_test
|
||||
VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []);
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s───────────┬─arr─────┐
|
||||
│ Hello │ [1,2] │
|
||||
│ World │ [3,4,5] │
|
||||
│ Goodbye │ [] │
|
||||
└─────────────┴─────────┘
|
||||
```
|
||||
|
||||
下面的例子使用 `ARRAY JOIN` 条款:
|
||||
|
||||
``` sql
|
||||
SELECT s, arr
|
||||
FROM arrays_test
|
||||
ARRAY JOIN arr;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─arr─┐
|
||||
│ Hello │ 1 │
|
||||
│ Hello │ 2 │
|
||||
│ World │ 3 │
|
||||
│ World │ 4 │
|
||||
│ World │ 5 │
|
||||
└───────┴─────┘
|
||||
```
|
||||
|
||||
下一个示例使用 `LEFT ARRAY JOIN` 条款:
|
||||
|
||||
``` sql
|
||||
SELECT s, arr
|
||||
FROM arrays_test
|
||||
LEFT ARRAY JOIN arr;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s───────────┬─arr─┐
|
||||
│ Hello │ 1 │
|
||||
│ Hello │ 2 │
|
||||
│ World │ 3 │
|
||||
│ World │ 4 │
|
||||
│ World │ 5 │
|
||||
│ Goodbye │ 0 │
|
||||
└─────────────┴─────┘
|
||||
```
|
||||
|
||||
## 使用别名 {#using-aliases}
|
||||
|
||||
可以为数组中的别名指定 `ARRAY JOIN` 条款 在这种情况下,数组项目可以通过此别名访问,但数组本身可以通过原始名称访问。 示例:
|
||||
|
||||
``` sql
|
||||
SELECT s, arr, a
|
||||
FROM arrays_test
|
||||
ARRAY JOIN arr AS a;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─arr─────┬─a─┐
|
||||
│ Hello │ [1,2] │ 1 │
|
||||
│ Hello │ [1,2] │ 2 │
|
||||
│ World │ [3,4,5] │ 3 │
|
||||
│ World │ [3,4,5] │ 4 │
|
||||
│ World │ [3,4,5] │ 5 │
|
||||
└───────┴─────────┴───┘
|
||||
```
|
||||
|
||||
使用别名,您可以执行 `ARRAY JOIN` 与外部阵列。 例如:
|
||||
|
||||
``` sql
|
||||
SELECT s, arr_external
|
||||
FROM arrays_test
|
||||
ARRAY JOIN [1, 2, 3] AS arr_external;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s───────────┬─arr_external─┐
|
||||
│ Hello │ 1 │
|
||||
│ Hello │ 2 │
|
||||
│ Hello │ 3 │
|
||||
│ World │ 1 │
|
||||
│ World │ 2 │
|
||||
│ World │ 3 │
|
||||
│ Goodbye │ 1 │
|
||||
│ Goodbye │ 2 │
|
||||
│ Goodbye │ 3 │
|
||||
└─────────────┴──────────────┘
|
||||
```
|
||||
|
||||
多个数组可以在逗号分隔 `ARRAY JOIN` 条款 在这种情况下, `JOIN` 与它们同时执行(直接和,而不是笛卡尔积)。 请注意,所有数组必须具有相同的大小。 示例:
|
||||
|
||||
``` sql
|
||||
SELECT s, arr, a, num, mapped
|
||||
FROM arrays_test
|
||||
ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─arr─────┬─a─┬─num─┬─mapped─┐
|
||||
│ Hello │ [1,2] │ 1 │ 1 │ 2 │
|
||||
│ Hello │ [1,2] │ 2 │ 2 │ 3 │
|
||||
│ World │ [3,4,5] │ 3 │ 1 │ 4 │
|
||||
│ World │ [3,4,5] │ 4 │ 2 │ 5 │
|
||||
│ World │ [3,4,5] │ 5 │ 3 │ 6 │
|
||||
└───────┴─────────┴───┴─────┴────────┘
|
||||
```
|
||||
|
||||
下面的例子使用 [arrayEnumerate](../../../sql-reference/functions/array-functions.md#array_functions-arrayenumerate) 功能:
|
||||
|
||||
``` sql
|
||||
SELECT s, arr, a, num, arrayEnumerate(arr)
|
||||
FROM arrays_test
|
||||
ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─arr─────┬─a─┬─num─┬─arrayEnumerate(arr)─┐
|
||||
│ Hello │ [1,2] │ 1 │ 1 │ [1,2] │
|
||||
│ Hello │ [1,2] │ 2 │ 2 │ [1,2] │
|
||||
│ World │ [3,4,5] │ 3 │ 1 │ [1,2,3] │
|
||||
│ World │ [3,4,5] │ 4 │ 2 │ [1,2,3] │
|
||||
│ World │ [3,4,5] │ 5 │ 3 │ [1,2,3] │
|
||||
└───────┴─────────┴───┴─────┴─────────────────────┘
|
||||
```
|
||||
|
||||
## 具有嵌套数据结构的数组连接 {#array-join-with-nested-data-structure}
|
||||
|
||||
`ARRAY JOIN` 也适用于 [嵌套数据结构](../../../sql-reference/data-types/nested-data-structures/nested.md):
|
||||
|
||||
``` sql
|
||||
CREATE TABLE nested_test
|
||||
(
|
||||
s String,
|
||||
nest Nested(
|
||||
x UInt8,
|
||||
y UInt32)
|
||||
) ENGINE = Memory;
|
||||
|
||||
INSERT INTO nested_test
|
||||
VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []);
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s───────┬─nest.x──┬─nest.y─────┐
|
||||
│ Hello │ [1,2] │ [10,20] │
|
||||
│ World │ [3,4,5] │ [30,40,50] │
|
||||
│ Goodbye │ [] │ [] │
|
||||
└─────────┴─────────┴────────────┘
|
||||
```
|
||||
|
||||
``` sql
|
||||
SELECT s, `nest.x`, `nest.y`
|
||||
FROM nested_test
|
||||
ARRAY JOIN nest;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─nest.x─┬─nest.y─┐
|
||||
│ Hello │ 1 │ 10 │
|
||||
│ Hello │ 2 │ 20 │
|
||||
│ World │ 3 │ 30 │
|
||||
│ World │ 4 │ 40 │
|
||||
│ World │ 5 │ 50 │
|
||||
└───────┴────────┴────────┘
|
||||
```
|
||||
|
||||
当指定嵌套数据结构的名称 `ARRAY JOIN`,意思是一样的 `ARRAY JOIN` 它包含的所有数组元素。 下面列出了示例:
|
||||
|
||||
``` sql
|
||||
SELECT s, `nest.x`, `nest.y`
|
||||
FROM nested_test
|
||||
ARRAY JOIN `nest.x`, `nest.y`;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─nest.x─┬─nest.y─┐
|
||||
│ Hello │ 1 │ 10 │
|
||||
│ Hello │ 2 │ 20 │
|
||||
│ World │ 3 │ 30 │
|
||||
│ World │ 4 │ 40 │
|
||||
│ World │ 5 │ 50 │
|
||||
└───────┴────────┴────────┘
|
||||
```
|
||||
|
||||
这种变化也是有道理的:
|
||||
|
||||
``` sql
|
||||
SELECT s, `nest.x`, `nest.y`
|
||||
FROM nested_test
|
||||
ARRAY JOIN `nest.x`;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─nest.x─┬─nest.y─────┐
|
||||
│ Hello │ 1 │ [10,20] │
|
||||
│ Hello │ 2 │ [10,20] │
|
||||
│ World │ 3 │ [30,40,50] │
|
||||
│ World │ 4 │ [30,40,50] │
|
||||
│ World │ 5 │ [30,40,50] │
|
||||
└───────┴────────┴────────────┘
|
||||
```
|
||||
|
||||
可以将别名用于嵌套数据结构,以便选择 `JOIN` 结果或源数组。 示例:
|
||||
|
||||
``` sql
|
||||
SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`
|
||||
FROM nested_test
|
||||
ARRAY JOIN nest AS n;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┐
|
||||
│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │
|
||||
│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │
|
||||
│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │
|
||||
│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │
|
||||
│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │
|
||||
└───────┴─────┴─────┴─────────┴────────────┘
|
||||
```
|
||||
|
||||
使用的例子 [arrayEnumerate](../../../sql-reference/functions/array-functions.md#array_functions-arrayenumerate) 功能:
|
||||
|
||||
``` sql
|
||||
SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num
|
||||
FROM nested_test
|
||||
ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num;
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─s─────┬─n.x─┬─n.y─┬─nest.x──┬─nest.y─────┬─num─┐
|
||||
│ Hello │ 1 │ 10 │ [1,2] │ [10,20] │ 1 │
|
||||
│ Hello │ 2 │ 20 │ [1,2] │ [10,20] │ 2 │
|
||||
│ World │ 3 │ 30 │ [3,4,5] │ [30,40,50] │ 1 │
|
||||
│ World │ 4 │ 40 │ [3,4,5] │ [30,40,50] │ 2 │
|
||||
│ World │ 5 │ 50 │ [3,4,5] │ [30,40,50] │ 3 │
|
||||
└───────┴─────┴─────┴─────────┴────────────┴─────┘
|
||||
```
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
运行时优化查询执行顺序 `ARRAY JOIN`. 虽然 `ARRAY JOIN` 必须始终之前指定 [WHERE](../../../sql-reference/statements/select/where.md)/[PREWHERE](../../../sql-reference/statements/select/prewhere.md) 子句中的查询,从技术上讲,它们可以以任何顺序执行,除非结果 `ARRAY JOIN` 用于过滤。 处理顺序由查询优化器控制。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/distinct.md
|
64
docs/zh/sql-reference/statements/select/distinct.md
Normal file
64
docs/zh/sql-reference/statements/select/distinct.md
Normal file
@ -0,0 +1,64 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: DISTINCT
|
||||
---
|
||||
|
||||
# DISTINCT子句 {#select-distinct}
|
||||
|
||||
如果 `SELECT DISTINCT` 如果指定,则查询结果中只保留唯一行。 因此,在结果中所有完全匹配的行集合中,只有一行将保留。
|
||||
|
||||
## 空处理 {#null-processing}
|
||||
|
||||
`DISTINCT` 适用于 [NULL](../../../sql-reference/syntax.md#null-literal) 就好像 `NULL` 是一个特定的值,并且 `NULL==NULL`. 换句话说,在 `DISTINCT` 结果,不同的组合 `NULL` 仅发生一次。 它不同于 `NULL` 在大多数其他上下文中进行处理。
|
||||
|
||||
## 替代办法 {#alternatives}
|
||||
|
||||
通过应用可以获得相同的结果 [GROUP BY](../../../sql-reference/statements/select/group-by.md) 在同一组值指定为 `SELECT` 子句,而不使用任何聚合函数。 但有几个区别 `GROUP BY` 方法:
|
||||
|
||||
- `DISTINCT` 可以一起应用 `GROUP BY`.
|
||||
- 当 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 省略和 [LIMIT](../../../sql-reference/statements/select/limit.md) 定义时,查询在读取所需数量的不同行后立即停止运行。
|
||||
- 数据块在处理时输出,而无需等待整个查询完成运行。
|
||||
|
||||
## 限制 {#limitations}
|
||||
|
||||
`DISTINCT` 如果不支持 `SELECT` 具有至少一个数组列。
|
||||
|
||||
## 例 {#examples}
|
||||
|
||||
ClickHouse支持使用 `DISTINCT` 和 `ORDER BY` 一个查询中不同列的子句。 该 `DISTINCT` 子句之前执行 `ORDER BY` 条款
|
||||
|
||||
示例表:
|
||||
|
||||
``` text
|
||||
┌─a─┬─b─┐
|
||||
│ 2 │ 1 │
|
||||
│ 1 │ 2 │
|
||||
│ 3 │ 3 │
|
||||
│ 2 │ 4 │
|
||||
└───┴───┘
|
||||
```
|
||||
|
||||
当与选择数据 `SELECT DISTINCT a FROM t1 ORDER BY b ASC` 查询,我们得到以下结果:
|
||||
|
||||
``` text
|
||||
┌─a─┐
|
||||
│ 2 │
|
||||
│ 1 │
|
||||
│ 3 │
|
||||
└───┘
|
||||
```
|
||||
|
||||
如果我们改变排序方向 `SELECT DISTINCT a FROM t1 ORDER BY b DESC`,我们得到以下结果:
|
||||
|
||||
``` text
|
||||
┌─a─┐
|
||||
│ 3 │
|
||||
│ 1 │
|
||||
│ 2 │
|
||||
└───┘
|
||||
```
|
||||
|
||||
行 `2, 4` 分拣前被切割。
|
||||
|
||||
在编程查询时考虑这种实现特异性。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/format.md
|
19
docs/zh/sql-reference/statements/select/format.md
Normal file
19
docs/zh/sql-reference/statements/select/format.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: FORMAT
|
||||
---
|
||||
|
||||
# 格式子句 {#format-clause}
|
||||
|
||||
ClickHouse支持广泛的 [序列化格式](../../../interfaces/formats.md) 可用于查询结果等。 有多种方法可以选择以下格式 `SELECT` 输出,其中之一是指定 `FORMAT format` 在查询结束时以任何特定格式获取结果数据。
|
||||
|
||||
特定的格式可以用于方便使用,与其他系统集成或性能增益。
|
||||
|
||||
## 默认格式 {#default-format}
|
||||
|
||||
如果 `FORMAT` 省略子句,使用默认格式,这取决于用于访问ClickHouse服务器的设置和接口。 为 [HTTP接口](../../../interfaces/http.md) 和 [命令行客户端](../../../interfaces/cli.md) 在批处理模式下,默认格式为 `TabSeparated`. 对于交互模式下的命令行客户端,默认格式为 `PrettyCompact` (它生成紧凑的人类可读表)。
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
使用命令行客户端时,数据始终以内部高效格式通过网络传递 (`Native`). 客户端独立解释 `FORMAT` 查询子句并格式化数据本身(从而减轻网络和服务器的额外负载)。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/from.md
|
45
docs/zh/sql-reference/statements/select/from.md
Normal file
45
docs/zh/sql-reference/statements/select/from.md
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: FROM
|
||||
---
|
||||
|
||||
# FROM条款 {#select-from}
|
||||
|
||||
该 `FROM` 子句指定从中读取数据的源:
|
||||
|
||||
- [表](../../../engines/table-engines/index.md)
|
||||
- [子查询](../../../sql-reference/statements/select/index.md) {## TODO: better link ##}
|
||||
- [表函数](../../../sql-reference/table-functions/index.md#table-functions)
|
||||
|
||||
[JOIN](../../../sql-reference/statements/select/join.md) 和 [ARRAY JOIN](../../../sql-reference/statements/select/array-join.md) 子句也可以用来扩展的功能 `FROM` 条款
|
||||
|
||||
子查询是另一个 `SELECT` 可以在括号内指定的查询 `FROM` 条款
|
||||
|
||||
`FROM` 子句可以包含多个数据源,用逗号分隔,这相当于执行 [CROSS JOIN](../../../sql-reference/statements/select/join.md) 在他们身上
|
||||
|
||||
## 最终修饰符 {#select-from-final}
|
||||
|
||||
当 `FINAL` 如果指定,ClickHouse会在返回结果之前完全合并数据,从而执行给定表引擎合并期间发生的所有数据转换。
|
||||
|
||||
它适用于从使用 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)-发动机系列(除了 `GraphiteMergeTree`). 还支持:
|
||||
|
||||
- [复制](../../../engines/table-engines/mergetree-family/replication.md) 版本 `MergeTree` 引擎
|
||||
- [查看](../../../engines/table-engines/special/view.md), [缓冲区](../../../engines/table-engines/special/buffer.md), [分布](../../../engines/table-engines/special/distributed.md),和 [MaterializedView](../../../engines/table-engines/special/materializedview.md) 在其他引擎上运行的引擎,只要它们是在创建 `MergeTree`-发动机表。
|
||||
|
||||
### 缺点 {#drawbacks}
|
||||
|
||||
使用的查询 `FINAL` 执行速度不如类似的查询那么快,因为:
|
||||
|
||||
- 查询在单个线程中执行,并在查询执行期间合并数据。
|
||||
- 查询与 `FINAL` 除了读取查询中指定的列之外,还读取主键列。
|
||||
|
||||
**在大多数情况下,避免使用 `FINAL`.** 常见的方法是使用假设后台进程的不同查询 `MergeTree` 引擎还没有发生,并通过应用聚合(例如,丢弃重复项)来处理它。 {## TODO: examples ##}
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
如果 `FROM` 子句被省略,数据将从读取 `system.one` 桌子
|
||||
该 `system.one` 表只包含一行(此表满足与其他Dbms中找到的双表相同的目的)。
|
||||
|
||||
若要执行查询,将从相应的表中提取查询中列出的所有列。 外部查询不需要的任何列都将从子查询中抛出。
|
||||
如果查询未列出任何列(例如, `SELECT count() FROM t`),无论如何都会从表中提取一些列(最小的列是首选),以便计算行数。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/group-by.md
|
133
docs/zh/sql-reference/statements/select/group-by.md
Normal file
133
docs/zh/sql-reference/statements/select/group-by.md
Normal file
@ -0,0 +1,133 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: GROUP BY
|
||||
---
|
||||
|
||||
# GROUP BY子句 {#select-group-by-clause}
|
||||
|
||||
`GROUP BY` 子句切换 `SELECT` 查询转换为聚合模式,其工作原理如下:
|
||||
|
||||
- `GROUP BY` 子句包含表达式列表(或单个表达式,其被认为是长度为1的列表)。 这份名单充当 “grouping key”,而每个单独的表达式将被称为 “key expressions”.
|
||||
- 在所有的表达式 [SELECT](../../../sql-reference/statements/select/index.md), [HAVING](../../../sql-reference/statements/select/having.md),和 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 条款 **必须** 基于键表达式进行计算 **或** 上 [聚合函数](../../../sql-reference/aggregate-functions/index.md) 在非键表达式(包括纯列)上。 换句话说,从表中选择的每个列必须用于键表达式或聚合函数内,但不能同时使用。
|
||||
- 聚合结果 `SELECT` 查询将包含尽可能多的行,因为有唯一值 “grouping key” 在源表中。 通常这会显着减少行数,通常是数量级,但不一定:如果所有行数保持不变 “grouping key” 值是不同的。
|
||||
|
||||
!!! note "注"
|
||||
还有一种额外的方法可以在表上运行聚合。 如果查询仅在聚合函数中包含表列,则 `GROUP BY clause` 可以省略,并且通过一个空的键集合来假定聚合。 这样的查询总是只返回一行。
|
||||
|
||||
## 空处理 {#null-processing}
|
||||
|
||||
对于分组,ClickHouse解释 [NULL](../../../sql-reference/syntax.md#null-literal) 作为一个值,并且 `NULL==NULL`. 它不同于 `NULL` 在大多数其他上下文中进行处理。
|
||||
|
||||
这里有一个例子来说明这意味着什么。
|
||||
|
||||
假设你有这张桌子:
|
||||
|
||||
``` text
|
||||
┌─x─┬────y─┐
|
||||
│ 1 │ 2 │
|
||||
│ 2 │ ᴺᵁᴸᴸ │
|
||||
│ 3 │ 2 │
|
||||
│ 3 │ 3 │
|
||||
│ 3 │ ᴺᵁᴸᴸ │
|
||||
└───┴──────┘
|
||||
```
|
||||
|
||||
查询 `SELECT sum(x), y FROM t_null_big GROUP BY y` 结果:
|
||||
|
||||
``` text
|
||||
┌─sum(x)─┬────y─┐
|
||||
│ 4 │ 2 │
|
||||
│ 3 │ 3 │
|
||||
│ 5 │ ᴺᵁᴸᴸ │
|
||||
└────────┴──────┘
|
||||
```
|
||||
|
||||
你可以看到 `GROUP BY` 为 `y = NULL` 总结 `x`,仿佛 `NULL` 是这个值。
|
||||
|
||||
如果你通过几个键 `GROUP BY`,结果会给你选择的所有组合,就好像 `NULL` 是一个特定的值。
|
||||
|
||||
## 使用总计修饰符 {#with-totals-modifier}
|
||||
|
||||
如果 `WITH TOTALS` 指定修饰符,将计算另一行。 此行将具有包含默认值(零或空行)的关键列,以及包含跨所有行计算值的聚合函数列( “total” 值)。
|
||||
|
||||
这个额外的行仅产生于 `JSON*`, `TabSeparated*`,和 `Pretty*` 格式,与其他行分开:
|
||||
|
||||
- 在 `JSON*` 格式,这一行是作为一个单独的输出 ‘totals’ 场。
|
||||
- 在 `TabSeparated*` 格式,该行位于主结果之后,前面有一个空行(在其他数据之后)。
|
||||
- 在 `Pretty*` 格式时,该行在主结果之后作为单独的表输出。
|
||||
- 在其他格式中,它不可用。
|
||||
|
||||
`WITH TOTALS` 可以以不同的方式运行时 [HAVING](../../../sql-reference/statements/select/having.md) 是存在的。 该行为取决于 `totals_mode` 设置。
|
||||
|
||||
### 配置合计处理 {#configuring-totals-processing}
|
||||
|
||||
默认情况下, `totals_mode = 'before_having'`. 在这种情况下, ‘totals’ 是跨所有行计算,包括那些不通过具有和 `max_rows_to_group_by`.
|
||||
|
||||
其他替代方案仅包括通过具有在 ‘totals’,并与设置不同的行为 `max_rows_to_group_by` 和 `group_by_overflow_mode = 'any'`.
|
||||
|
||||
`after_having_exclusive` – Don't include rows that didn't pass through `max_rows_to_group_by`. 换句话说, ‘totals’ 将有少于或相同数量的行,因为它会 `max_rows_to_group_by` 被省略。
|
||||
|
||||
`after_having_inclusive` – Include all the rows that didn't pass through ‘max\_rows\_to\_group\_by’ 在 ‘totals’. 换句话说, ‘totals’ 将有多个或相同数量的行,因为它会 `max_rows_to_group_by` 被省略。
|
||||
|
||||
`after_having_auto` – Count the number of rows that passed through HAVING. If it is more than a certain amount (by default, 50%), include all the rows that didn't pass through ‘max\_rows\_to\_group\_by’ 在 ‘totals’. 否则,不包括它们。
|
||||
|
||||
`totals_auto_threshold` – By default, 0.5. The coefficient for `after_having_auto`.
|
||||
|
||||
如果 `max_rows_to_group_by` 和 `group_by_overflow_mode = 'any'` 不使用,所有的变化 `after_having` 是相同的,你可以使用它们中的任何一个(例如, `after_having_auto`).
|
||||
|
||||
您可以使用 `WITH TOTALS` 在子查询中,包括在子查询 [JOIN](../../../sql-reference/statements/select/join.md) 子句(在这种情况下,将各自的总值合并)。
|
||||
|
||||
## 例 {#examples}
|
||||
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
count(),
|
||||
median(FetchTiming > 60 ? 60 : FetchTiming),
|
||||
count() - sum(Refresh)
|
||||
FROM hits
|
||||
```
|
||||
|
||||
但是,与标准SQL相比,如果表没有任何行(根本没有任何行,或者在使用WHERE to filter之后没有任何行),则返回一个空结果,而不是来自包含聚合函数初始值的行之
|
||||
|
||||
相对于MySQL(并且符合标准SQL),您无法获取不在键或聚合函数(常量表达式除外)中的某些列的某些值。 要解决此问题,您可以使用 ‘any’ 聚合函数(获取第一个遇到的值)或 ‘min/max’.
|
||||
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
domainWithoutWWW(URL) AS domain,
|
||||
count(),
|
||||
any(Title) AS title -- getting the first occurred page header for each domain.
|
||||
FROM hits
|
||||
GROUP BY domain
|
||||
```
|
||||
|
||||
对于遇到的每个不同的键值, `GROUP BY` 计算一组聚合函数值。
|
||||
|
||||
`GROUP BY` 不支持数组列。
|
||||
|
||||
不能将常量指定为聚合函数的参数。 示例: `sum(1)`. 相反,你可以摆脱常数。 示例: `count()`.
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
聚合是面向列的DBMS最重要的功能之一,因此它的实现是ClickHouse中最优化的部分之一。 默认情况下,聚合使用哈希表在内存中完成。 它有40+的专业化是自动选择取决于 “grouping key” 数据类型。
|
||||
|
||||
### 在外部存储器中分组 {#select-group-by-in-external-memory}
|
||||
|
||||
您可以启用将临时数据转储到磁盘以限制内存使用期间 `GROUP BY`.
|
||||
该 [max\_bytes\_before\_external\_group\_by](../../../operations/settings/settings.md#settings-max_bytes_before_external_group_by) 设置确定倾销的阈值RAM消耗 `GROUP BY` 临时数据到文件系统。 如果设置为0(默认值),它将被禁用。
|
||||
|
||||
使用时 `max_bytes_before_external_group_by`,我们建议您设置 `max_memory_usage` 大约两倍高。 这是必要的,因为聚合有两个阶段:读取数据和形成中间数据(1)和合并中间数据(2)。 将数据转储到文件系统只能在阶段1中发生。 如果未转储临时数据,则阶段2可能需要与阶段1相同的内存量。
|
||||
|
||||
例如,如果 [max\_memory\_usage](../../../operations/settings/settings.md#settings_max_memory_usage) 设置为10000000000,你想使用外部聚合,这是有意义的设置 `max_bytes_before_external_group_by` 到10000000000,和 `max_memory_usage` 到200亿。 当触发外部聚合(如果至少有一个临时数据转储)时,RAM的最大消耗仅略高于 `max_bytes_before_external_group_by`.
|
||||
|
||||
通过分布式查询处理,在远程服务器上执行外部聚合。 为了使请求者服务器只使用少量的RAM,设置 `distributed_aggregation_memory_efficient` 到1。
|
||||
|
||||
当合并数据刷新到磁盘时,以及当合并来自远程服务器的结果时, `distributed_aggregation_memory_efficient` 设置被启用,消耗高达 `1/256 * the_number_of_threads` 从RAM的总量。
|
||||
|
||||
当启用外部聚合时,如果有小于 `max_bytes_before_external_group_by` of data (i.e. data was not flushed), the query runs just as fast as without external aggregation. If any temporary data was flushed, the run time will be several times longer (approximately three times).
|
||||
|
||||
如果你有一个 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 用一个 [LIMIT](../../../sql-reference/statements/select/limit.md) 后 `GROUP BY`,然后使用的RAM的量取决于数据的量 `LIMIT`,不是在整个表。 但如果 `ORDER BY` 没有 `LIMIT`,不要忘记启用外部排序 (`max_bytes_before_external_sort`).
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/having.md
|
15
docs/zh/sql-reference/statements/select/having.md
Normal file
15
docs/zh/sql-reference/statements/select/having.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: HAVING
|
||||
---
|
||||
|
||||
# 有条款 {#having-clause}
|
||||
|
||||
允许过滤由以下方式生成的聚合结果 [GROUP BY](../../../sql-reference/statements/select/group-by.md). 它类似于 [WHERE](../../../sql-reference/statements/select/where.md) 条款,但不同的是 `WHERE` 在聚合之前执行,而 `HAVING` 之后进行。
|
||||
|
||||
可以从以下引用聚合结果 `SELECT` 中的条款 `HAVING` 子句由他们的化名。 或者, `HAVING` 子句可以筛选查询结果中未返回的其他聚合的结果。
|
||||
|
||||
## 限制 {#limitations}
|
||||
|
||||
`HAVING` 如果不执行聚合,则无法使用。 使用 `WHERE` 相反。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/index.md
|
164
docs/zh/sql-reference/statements/select/index.md
Normal file
164
docs/zh/sql-reference/statements/select/index.md
Normal file
@ -0,0 +1,164 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
title: SELECT Query
|
||||
toc_folder_title: SELECT
|
||||
toc_priority: 33
|
||||
toc_title: "\u6982\u8FF0"
|
||||
---
|
||||
|
||||
# 选择查询 {#select-queries-syntax}
|
||||
|
||||
`SELECT` 查询执行数据检索。 默认情况下,请求的数据返回给客户端,同时与 [INSERT INTO](../../../sql-reference/statements/insert-into.md) 它可以被转发到不同的表。
|
||||
|
||||
## 语法 {#syntax}
|
||||
|
||||
``` sql
|
||||
[WITH expr_list|(subquery)]
|
||||
SELECT [DISTINCT] expr_list
|
||||
[FROM [db.]table | (subquery) | table_function] [FINAL]
|
||||
[SAMPLE sample_coeff]
|
||||
[ARRAY JOIN ...]
|
||||
[GLOBAL] [ANY|ALL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER] JOIN (subquery)|table USING columns_list
|
||||
[PREWHERE expr]
|
||||
[WHERE expr]
|
||||
[GROUP BY expr_list] [WITH TOTALS]
|
||||
[HAVING expr]
|
||||
[ORDER BY expr_list]
|
||||
[LIMIT [offset_value, ]n BY columns]
|
||||
[LIMIT [n, ]m]
|
||||
[UNION ALL ...]
|
||||
[INTO OUTFILE filename]
|
||||
[FORMAT format]
|
||||
```
|
||||
|
||||
所有子句都是可选的,但紧接在后面的必需表达式列表除外 `SELECT` 这是更详细的复盖 [下面](#select-clause).
|
||||
|
||||
每个可选子句的具体内容在单独的部分中进行了介绍,这些部分按与执行顺序相同的顺序列出:
|
||||
|
||||
- [WITH条款](../../../sql-reference/statements/select/with.md)
|
||||
- [FROM条款](../../../sql-reference/statements/select/from.md)
|
||||
- [示例子句](../../../sql-reference/statements/select/sample.md)
|
||||
- [JOIN子句](../../../sql-reference/statements/select/join.md)
|
||||
- [PREWHERE条款](../../../sql-reference/statements/select/prewhere.md)
|
||||
- [WHERE条款](../../../sql-reference/statements/select/where.md)
|
||||
- [GROUP BY子句](../../../sql-reference/statements/select/group-by.md)
|
||||
- [限制条款](../../../sql-reference/statements/select/limit-by.md)
|
||||
- [有条款](../../../sql-reference/statements/select/having.md)
|
||||
- [SELECT子句](#select-clause)
|
||||
- [DISTINCT子句](../../../sql-reference/statements/select/distinct.md)
|
||||
- [限制条款](../../../sql-reference/statements/select/limit.md)
|
||||
- [UNION ALL条款](../../../sql-reference/statements/select/union-all.md)
|
||||
- [INTO OUTFILE条款](../../../sql-reference/statements/select/into-outfile.md)
|
||||
- [格式子句](../../../sql-reference/statements/select/format.md)
|
||||
|
||||
## SELECT子句 {#select-clause}
|
||||
|
||||
[表达式](../../../sql-reference/syntax.md#syntax-expressions) 在指定 `SELECT` 子句是在上述子句中的所有操作完成后计算的。 这些表达式的工作方式就好像它们应用于结果中的单独行一样。 如果在表达式 `SELECT` 子句包含聚合函数,然后ClickHouse处理过程中用作其参数的聚合函数和表达式 [GROUP BY](../../../sql-reference/statements/select/group-by.md) 聚合。
|
||||
|
||||
如果要在结果中包含所有列,请使用星号 (`*`)符号。 例如, `SELECT * FROM ...`.
|
||||
|
||||
将结果中的某些列与 [re2](https://en.wikipedia.org/wiki/RE2_(software)) 正则表达式,您可以使用 `COLUMNS` 表达。
|
||||
|
||||
``` sql
|
||||
COLUMNS('regexp')
|
||||
```
|
||||
|
||||
例如,考虑表:
|
||||
|
||||
``` sql
|
||||
CREATE TABLE default.col_names (aa Int8, ab Int8, bc Int8) ENGINE = TinyLog
|
||||
```
|
||||
|
||||
以下查询从包含以下内容的所有列中选择数据 `a` 在他们的名字符号。
|
||||
|
||||
``` sql
|
||||
SELECT COLUMNS('a') FROM col_names
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─aa─┬─ab─┐
|
||||
│ 1 │ 1 │
|
||||
└────┴────┘
|
||||
```
|
||||
|
||||
所选列不按字母顺序返回。
|
||||
|
||||
您可以使用多个 `COLUMNS` 查询中的表达式并将函数应用于它们。
|
||||
|
||||
例如:
|
||||
|
||||
``` sql
|
||||
SELECT COLUMNS('a'), COLUMNS('c'), toTypeName(COLUMNS('c')) FROM col_names
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─aa─┬─ab─┬─bc─┬─toTypeName(bc)─┐
|
||||
│ 1 │ 1 │ 1 │ Int8 │
|
||||
└────┴────┴────┴────────────────┘
|
||||
```
|
||||
|
||||
由返回的每一列 `COLUMNS` 表达式作为单独的参数传递给函数。 如果函数支持其他参数,您也可以将其他参数传递给函数。 使用函数时要小心。 如果函数不支持您传递给它的参数数,ClickHouse将引发异常。
|
||||
|
||||
例如:
|
||||
|
||||
``` sql
|
||||
SELECT COLUMNS('a') + COLUMNS('c') FROM col_names
|
||||
```
|
||||
|
||||
``` text
|
||||
Received exception from server (version 19.14.1):
|
||||
Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Number of arguments for function plus doesn't match: passed 3, should be 2.
|
||||
```
|
||||
|
||||
在这个例子中, `COLUMNS('a')` 返回两列: `aa` 和 `ab`. `COLUMNS('c')` 返回 `bc` 列。 该 `+` 运算符不能应用于3个参数,因此ClickHouse引发一个带有相关消息的异常。
|
||||
|
||||
匹配的列 `COLUMNS` 表达式可以具有不同的数据类型。 如果 `COLUMNS` 不匹配任何列,并且是唯一的表达式 `SELECT`,ClickHouse抛出异常。
|
||||
|
||||
### 星号 {#asterisk}
|
||||
|
||||
您可以在查询的任何部分而不是表达式中添加星号。 分析查询时,星号将展开为所有表列的列表(不包括 `MATERIALIZED` 和 `ALIAS` 列)。 只有少数情况下使用星号是合理的:
|
||||
|
||||
- 创建表转储时。
|
||||
- 对于只包含几列的表,例如系统表。
|
||||
- 获取有关表中哪些列的信息。 在这种情况下,设置 `LIMIT 1`. 但最好使用 `DESC TABLE` 查询。
|
||||
- 当对少量柱进行强过滤时,使用 `PREWHERE`.
|
||||
- 在子查询中(因为外部查询不需要的列从子查询中排除)。
|
||||
|
||||
在所有其他情况下,我们不建议使用星号,因为它只给你一个列DBMS的缺点,而不是优点。 换句话说,不建议使用星号。
|
||||
|
||||
### 极端值 {#extreme-values}
|
||||
|
||||
除了结果之外,还可以获取结果列的最小值和最大值。 要做到这一点,设置 **极端** 设置为1。 最小值和最大值是针对数字类型、日期和带有时间的日期计算的。 对于其他列,默认值为输出。
|
||||
|
||||
An extra two rows are calculated – the minimums and maximums, respectively. These extra two rows are output in `JSON*`, `TabSeparated*`,和 `Pretty*` [格式](../../../interfaces/formats.md),与其他行分开。 它们不是其他格式的输出。
|
||||
|
||||
在 `JSON*` 格式时,极端值在一个单独的输出 ‘extremes’ 场。 在 `TabSeparated*` 格式中,该行来的主要结果之后,和之后 ‘totals’ 如果存在。 它前面有一个空行(在其他数据之后)。 在 `Pretty*` 格式中,该行被输出为一个单独的表之后的主结果,和之后 `totals` 如果存在。
|
||||
|
||||
极值计算之前的行 `LIMIT`,但之后 `LIMIT BY`. 但是,使用时 `LIMIT offset, size`,之前的行 `offset` 都包含在 `extremes`. 在流请求中,结果还可能包括少量通过的行 `LIMIT`.
|
||||
|
||||
### 注 {#notes}
|
||||
|
||||
您可以使用同义词 (`AS` 别名)在查询的任何部分。
|
||||
|
||||
该 `GROUP BY` 和 `ORDER BY` 子句不支持位置参数。 这与MySQL相矛盾,但符合标准SQL。 例如, `GROUP BY 1, 2` will be interpreted as grouping by constants (i.e. aggregation of all rows into one).
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
如果查询省略 `DISTINCT`, `GROUP BY` 和 `ORDER BY` 条款和 `IN` 和 `JOIN` 子查询,查询将被完全流处理,使用O(1)量的RAM。 否则,如果未指定适当的限制,则查询可能会消耗大量RAM:
|
||||
|
||||
- `max_memory_usage`
|
||||
- `max_rows_to_group_by`
|
||||
- `max_rows_to_sort`
|
||||
- `max_rows_in_distinct`
|
||||
- `max_bytes_in_distinct`
|
||||
- `max_rows_in_set`
|
||||
- `max_bytes_in_set`
|
||||
- `max_rows_in_join`
|
||||
- `max_bytes_in_join`
|
||||
- `max_bytes_before_external_sort`
|
||||
- `max_bytes_before_external_group_by`
|
||||
|
||||
有关详细信息,请参阅部分 “Settings”. 可以使用外部排序(将临时表保存到磁盘)和外部聚合。
|
||||
|
||||
{## [原始文章](https://clickhouse.tech/docs/en/sql-reference/statements/select/) ##}
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/into-outfile.md
|
15
docs/zh/sql-reference/statements/select/into-outfile.md
Normal file
15
docs/zh/sql-reference/statements/select/into-outfile.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: INTO OUTFILE
|
||||
---
|
||||
|
||||
# INTO OUTFILE条款 {#into-outfile-clause}
|
||||
|
||||
添加 `INTO OUTFILE filename` 子句(其中filename是字符串文字) `SELECT query` 将其输出重定向到客户端上的指定文件。
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
- 此功能是在可用 [命令行客户端](../../../interfaces/cli.md) 和 [ツ环板-ョツ嘉ッツ偲](../../../operations/utilities/clickhouse-local.md). 因此,通过发送查询 [HTTP接口](../../../interfaces/http.md) 都会失败
|
||||
- 如果具有相同文件名的文件已经存在,则查询将失败。
|
||||
- 默认值 [输出格式](../../../interfaces/formats.md) 是 `TabSeparated` (就像在命令行客户端批处理模式中一样)。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/join.md
|
198
docs/zh/sql-reference/statements/select/join.md
Normal file
198
docs/zh/sql-reference/statements/select/join.md
Normal file
@ -0,0 +1,198 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: JOIN
|
||||
---
|
||||
|
||||
# JOIN子句 {#select-join}
|
||||
|
||||
Join通过使用一个或多个表的公共值合并来自一个或多个表的列来生成新表。 它是支持SQL的数据库中的常见操作,它对应于 [关系代数](https://en.wikipedia.org/wiki/Relational_algebra#Joins_and_join-like_operators) 加入。 一个表连接的特殊情况通常被称为 “self-join”.
|
||||
|
||||
语法:
|
||||
|
||||
``` sql
|
||||
SELECT <expr_list>
|
||||
FROM <left_table>
|
||||
[GLOBAL] [ANY|ALL|ASOF] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER|SEMI|ANTI] JOIN <right_table>
|
||||
(ON <expr_list>)|(USING <column_list>) ...
|
||||
```
|
||||
|
||||
从表达式 `ON` 从子句和列 `USING` 子句被称为 “join keys”. 除非另有说明,加入产生一个 [笛卡尔积](https://en.wikipedia.org/wiki/Cartesian_product) 从具有匹配的行 “join keys”,这可能会产生比源表更多的行的结果。
|
||||
|
||||
## 支持的联接类型 {#select-join-types}
|
||||
|
||||
所有标准 [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) 支持类型:
|
||||
|
||||
- `INNER JOIN`,只返回匹配的行。
|
||||
- `LEFT OUTER JOIN`,除了匹配的行之外,还返回左表中的非匹配行。
|
||||
- `RIGHT OUTER JOIN`,除了匹配的行之外,还返回右表中的非匹配行。
|
||||
- `FULL OUTER JOIN`,除了匹配的行之外,还会返回两个表中的非匹配行。
|
||||
- `CROSS JOIN`,产生整个表的笛卡尔积, “join keys” 是 **不** 指定。
|
||||
|
||||
`JOIN` 没有指定类型暗示 `INNER`. 关键字 `OUTER` 可以安全地省略。 替代语法 `CROSS JOIN` 在指定多个表 [FROM条款](../../../sql-reference/statements/select/from.md) 用逗号分隔。
|
||||
|
||||
ClickHouse中提供的其他联接类型:
|
||||
|
||||
- `LEFT SEMI JOIN` 和 `RIGHT SEMI JOIN`,白名单 “join keys”,而不产生笛卡尔积。
|
||||
- `LEFT ANTI JOIN` 和 `RIGHT ANTI JOIN`,黑名单 “join keys”,而不产生笛卡尔积。
|
||||
|
||||
## 严格 {#select-join-strictness}
|
||||
|
||||
修改如何匹配 “join keys” 执行
|
||||
|
||||
- `ALL` — The standard `JOIN` sql中的行为如上所述。 默认值。
|
||||
- `ANY` — Partially (for opposite side of `LEFT` 和 `RIGHT`)或完全(为 `INNER` 和 `FULL`)禁用笛卡尔积为标准 `JOIN` 类型。
|
||||
- `ASOF` — For joining sequences with a non-exact match. `ASOF JOIN` 用法描述如下。
|
||||
|
||||
!!! note "注"
|
||||
可以使用以下方式复盖默认的严格性值 [join\_default\_strictness](../../../operations/settings/settings.md#settings-join_default_strictness) 设置。
|
||||
|
||||
Also the behavior of ClickHouse server for `ANY JOIN` operations depends on the [any_join_distinct_right_table_keys](../../../operations/settings/settings.md#any_join_distinct_right_table_keys) setting.
|
||||
|
||||
### ASOF加入使用 {#asof-join-usage}
|
||||
|
||||
`ASOF JOIN` 当您需要连接没有完全匹配的记录时非常有用。
|
||||
|
||||
算法需要表中的特殊列。 本专栏:
|
||||
|
||||
- 必须包含有序序列。
|
||||
- 可以是以下类型之一: [Int*,UInt*](../../../sql-reference/data-types/int-uint.md), [浮动\*](../../../sql-reference/data-types/float.md), [日期](../../../sql-reference/data-types/date.md), [日期时间](../../../sql-reference/data-types/datetime.md), [十进制\*](../../../sql-reference/data-types/decimal.md).
|
||||
- 不能是唯一的列 `JOIN` 条款
|
||||
|
||||
语法 `ASOF JOIN ... ON`:
|
||||
|
||||
``` sql
|
||||
SELECT expressions_list
|
||||
FROM table_1
|
||||
ASOF LEFT JOIN table_2
|
||||
ON equi_cond AND closest_match_cond
|
||||
```
|
||||
|
||||
您可以使用任意数量的相等条件和恰好一个最接近的匹配条件。 例如, `SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`.
|
||||
|
||||
支持最接近匹配的条件: `>`, `>=`, `<`, `<=`.
|
||||
|
||||
语法 `ASOF JOIN ... USING`:
|
||||
|
||||
``` sql
|
||||
SELECT expressions_list
|
||||
FROM table_1
|
||||
ASOF JOIN table_2
|
||||
USING (equi_column1, ... equi_columnN, asof_column)
|
||||
```
|
||||
|
||||
`ASOF JOIN` 用途 `equi_columnX` 对于加入平等和 `asof_column` 用于加入与最接近的比赛 `table_1.asof_column >= table_2.asof_column` 条件。 该 `asof_column` 列总是在最后一个 `USING` 条款
|
||||
|
||||
例如,请考虑下表:
|
||||
|
||||
table_1 table_2
|
||||
event | ev_time | user_id event | ev_time | user_id
|
||||
----------|---------|---------- ----------|---------|----------
|
||||
... ...
|
||||
event_1_1 | 12:00 | 42 event_2_1 | 11:59 | 42
|
||||
... event_2_2 | 12:30 | 42
|
||||
event_1_2 | 13:00 | 42 event_2_3 | 13:00 | 42
|
||||
... ...
|
||||
|
||||
`ASOF JOIN` 可以从用户事件的时间戳 `table_1` 并找到一个事件 `table_2` 其中时间戳最接近事件的时间戳 `table_1` 对应于最接近的匹配条件。 如果可用,则相等的时间戳值是最接近的值。 在这里,该 `user_id` 列可用于连接相等和 `ev_time` 列可用于在最接近的匹配加入。 在我们的例子中, `event_1_1` 可以加入 `event_2_1` 和 `event_1_2` 可以加入 `event_2_3`,但是 `event_2_2` 不能加入。
|
||||
|
||||
!!! note "注"
|
||||
`ASOF` 加入是 **不** 支持在 [加入我们](../../../engines/table-engines/special/join.md) 表引擎。
|
||||
|
||||
## 分布式联接 {#global-join}
|
||||
|
||||
有两种方法可以执行涉及分布式表的join:
|
||||
|
||||
- 当使用正常 `JOIN`,将查询发送到远程服务器。 为了创建正确的表,在每个子查询上运行子查询,并使用此表执行联接。 换句话说,在每个服务器上单独形成右表。
|
||||
- 使用时 `GLOBAL ... JOIN`,首先请求者服务器运行一个子查询来计算正确的表。 此临时表将传递到每个远程服务器,并使用传输的临时数据对其运行查询。
|
||||
|
||||
使用时要小心 `GLOBAL`. 有关详细信息,请参阅 [分布式子查询](../../../sql-reference/operators/in.md#select-distributed-subqueries) 科。
|
||||
|
||||
## 使用建议 {#usage-recommendations}
|
||||
|
||||
### 处理空单元格或空单元格 {#processing-of-empty-or-null-cells}
|
||||
|
||||
在连接表时,可能会出现空单元格。 设置 [join\_use\_nulls](../../../operations/settings/settings.md#join_use_nulls) 定义ClickHouse如何填充这些单元格。
|
||||
|
||||
如果 `JOIN` 键是 [可为空](../../../sql-reference/data-types/nullable.md) 字段,其中至少有一个键具有值的行 [NULL](../../../sql-reference/syntax.md#null-literal) 没有加入。
|
||||
|
||||
### 语法 {#syntax}
|
||||
|
||||
在指定的列 `USING` 两个子查询中必须具有相同的名称,并且其他列必须以不同的方式命名。 您可以使用别名更改子查询中的列名。
|
||||
|
||||
该 `USING` 子句指定一个或多个要联接的列,这将建立这些列的相等性。 列的列表设置不带括号。 不支持更复杂的连接条件。
|
||||
|
||||
### 语法限制 {#syntax-limitations}
|
||||
|
||||
对于多个 `JOIN` 单个子句 `SELECT` 查询:
|
||||
|
||||
- 通过以所有列 `*` 仅在联接表时才可用,而不是子查询。
|
||||
- 该 `PREWHERE` 条款不可用。
|
||||
|
||||
为 `ON`, `WHERE`,和 `GROUP BY` 条款:
|
||||
|
||||
- 任意表达式不能用于 `ON`, `WHERE`,和 `GROUP BY` 子句,但你可以定义一个表达式 `SELECT` 子句,然后通过别名在这些子句中使用它。
|
||||
|
||||
### 性能 {#performance}
|
||||
|
||||
当运行 `JOIN`,与查询的其他阶段相关的执行顺序没有优化。 连接(在右表中搜索)在过滤之前运行 `WHERE` 和聚集之前。
|
||||
|
||||
每次使用相同的查询运行 `JOIN`,子查询再次运行,因为结果未缓存。 为了避免这种情况,使用特殊的 [加入我们](../../../engines/table-engines/special/join.md) 表引擎,它是一个用于连接的准备好的数组,总是在RAM中。
|
||||
|
||||
在某些情况下,使用效率更高 [IN](../../../sql-reference/operators/in.md) 而不是 `JOIN`.
|
||||
|
||||
如果你需要一个 `JOIN` 对于连接维度表(这些是包含维度属性的相对较小的表,例如广告活动的名称), `JOIN` 由于每个查询都会重新访问正确的表,因此可能不太方便。 对于这种情况下,有一个 “external dictionaries” 您应该使用的功能 `JOIN`. 有关详细信息,请参阅 [外部字典](../../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) 科。
|
||||
|
||||
### 内存限制 {#memory-limitations}
|
||||
|
||||
默认情况下,ClickHouse使用 [哈希联接](https://en.wikipedia.org/wiki/Hash_join) 算法。 ClickHouse采取 `<right_table>` 并在RAM中为其创建哈希表。 在某个内存消耗阈值之后,ClickHouse回退到合并联接算法。
|
||||
|
||||
如果需要限制联接操作内存消耗,请使用以下设置:
|
||||
|
||||
- [max\_rows\_in\_join](../../../operations/settings/query-complexity.md#settings-max_rows_in_join) — Limits number of rows in the hash table.
|
||||
- [max\_bytes\_in\_join](../../../operations/settings/query-complexity.md#settings-max_bytes_in_join) — Limits size of the hash table.
|
||||
|
||||
当任何这些限制达到,ClickHouse作为 [join\_overflow\_mode](../../../operations/settings/query-complexity.md#settings-join_overflow_mode) 设置指示。
|
||||
|
||||
## 例 {#examples}
|
||||
|
||||
示例:
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
CounterID,
|
||||
hits,
|
||||
visits
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
CounterID,
|
||||
count() AS hits
|
||||
FROM test.hits
|
||||
GROUP BY CounterID
|
||||
) ANY LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
CounterID,
|
||||
sum(Sign) AS visits
|
||||
FROM test.visits
|
||||
GROUP BY CounterID
|
||||
) USING CounterID
|
||||
ORDER BY hits DESC
|
||||
LIMIT 10
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─CounterID─┬───hits─┬─visits─┐
|
||||
│ 1143050 │ 523264 │ 13665 │
|
||||
│ 731962 │ 475698 │ 102716 │
|
||||
│ 722545 │ 337212 │ 108187 │
|
||||
│ 722889 │ 252197 │ 10547 │
|
||||
│ 2237260 │ 196036 │ 9522 │
|
||||
│ 23057320 │ 147211 │ 7689 │
|
||||
│ 722818 │ 90109 │ 17847 │
|
||||
│ 48221 │ 85379 │ 4652 │
|
||||
│ 19762435 │ 77807 │ 7026 │
|
||||
│ 722884 │ 77492 │ 11056 │
|
||||
└───────────┴────────┴────────┘
|
||||
```
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/limit-by.md
|
72
docs/zh/sql-reference/statements/select/limit-by.md
Normal file
72
docs/zh/sql-reference/statements/select/limit-by.md
Normal file
@ -0,0 +1,72 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: LIMIT BY
|
||||
---
|
||||
|
||||
# 限制条款 {#limit-by-clause}
|
||||
|
||||
与查询 `LIMIT n BY expressions` 子句选择第一个 `n` 每个不同值的行 `expressions`. 的关键 `LIMIT BY` 可以包含任意数量的 [表达式](../../../sql-reference/syntax.md#syntax-expressions).
|
||||
|
||||
ClickHouse支持以下语法变体:
|
||||
|
||||
- `LIMIT [offset_value, ]n BY expressions`
|
||||
- `LIMIT n OFFSET offset_value BY expressions`
|
||||
|
||||
在查询处理过程中,ClickHouse会选择按排序键排序的数据。 排序键使用以下命令显式设置 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 子句或隐式作为表引擎的属性。 然后ClickHouse应用 `LIMIT n BY expressions` 并返回第一 `n` 每个不同组合的行 `expressions`. 如果 `OFFSET` 被指定,则对于每个数据块属于一个不同的组合 `expressions`,ClickHouse跳过 `offset_value` 从块开始的行数,并返回最大值 `n` 行的结果。 如果 `offset_value` 如果数据块中的行数大于数据块中的行数,ClickHouse将从该块返回零行。
|
||||
|
||||
!!! note "注"
|
||||
`LIMIT BY` 是不相关的 [LIMIT](../../../sql-reference/statements/select/limit.md). 它们都可以在同一个查询中使用。
|
||||
|
||||
## 例 {#examples}
|
||||
|
||||
样品表:
|
||||
|
||||
``` sql
|
||||
CREATE TABLE limit_by(id Int, val Int) ENGINE = Memory;
|
||||
INSERT INTO limit_by VALUES (1, 10), (1, 11), (1, 12), (2, 20), (2, 21);
|
||||
```
|
||||
|
||||
查询:
|
||||
|
||||
``` sql
|
||||
SELECT * FROM limit_by ORDER BY id, val LIMIT 2 BY id
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─id─┬─val─┐
|
||||
│ 1 │ 10 │
|
||||
│ 1 │ 11 │
|
||||
│ 2 │ 20 │
|
||||
│ 2 │ 21 │
|
||||
└────┴─────┘
|
||||
```
|
||||
|
||||
``` sql
|
||||
SELECT * FROM limit_by ORDER BY id, val LIMIT 1, 2 BY id
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─id─┬─val─┐
|
||||
│ 1 │ 11 │
|
||||
│ 1 │ 12 │
|
||||
│ 2 │ 21 │
|
||||
└────┴─────┘
|
||||
```
|
||||
|
||||
该 `SELECT * FROM limit_by ORDER BY id, val LIMIT 2 OFFSET 1 BY id` 查询返回相同的结果。
|
||||
|
||||
以下查询返回每个引用的前5个引用 `domain, device_type` 最多可与100行配对 (`LIMIT n BY + LIMIT`).
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
domainWithoutWWW(URL) AS domain,
|
||||
domainWithoutWWW(REFERRER_URL) AS referrer,
|
||||
device_type,
|
||||
count() cnt
|
||||
FROM hits
|
||||
GROUP BY domain, referrer, device_type
|
||||
ORDER BY cnt DESC
|
||||
LIMIT 5 BY domain, device_type
|
||||
LIMIT 100
|
||||
```
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/limit.md
|
15
docs/zh/sql-reference/statements/select/limit.md
Normal file
15
docs/zh/sql-reference/statements/select/limit.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: LIMIT
|
||||
---
|
||||
|
||||
# 限制条款 {#limit-clause}
|
||||
|
||||
`LIMIT m` 允许选择第一个 `m` 结果中的行。
|
||||
|
||||
`LIMIT n, m` 允许选择 `m` 跳过第一个结果后的行 `n` 行。 该 `LIMIT m OFFSET n` 语法是等效的。
|
||||
|
||||
`n` 和 `m` 必须是非负整数。
|
||||
|
||||
如果没有 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 子句显式排序结果,结果的行选择可能是任意的和非确定性的。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/order-by.md
|
73
docs/zh/sql-reference/statements/select/order-by.md
Normal file
73
docs/zh/sql-reference/statements/select/order-by.md
Normal file
@ -0,0 +1,73 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: ORDER BY
|
||||
---
|
||||
|
||||
# 按条款订购 {#select-order-by}
|
||||
|
||||
该 `ORDER BY` 子句包含一个表达式列表,每个表达式都可以用 `DESC` (降序)或 `ASC` (升序)修饰符确定排序方向。 如果未指定方向, `ASC` 假设,所以它通常被省略。 排序方向适用于单个表达式,而不适用于整个列表。 示例: `ORDER BY Visits DESC, SearchPhrase`
|
||||
|
||||
对于排序表达式列表具有相同值的行以任意顺序输出,也可以是非确定性的(每次都不同)。
|
||||
如果省略ORDER BY子句,则行的顺序也是未定义的,并且可能也是非确定性的。
|
||||
|
||||
## 特殊值的排序 {#sorting-of-special-values}
|
||||
|
||||
有两种方法 `NaN` 和 `NULL` 排序顺序:
|
||||
|
||||
- 默认情况下或与 `NULLS LAST` 修饰符:首先是值,然后 `NaN`,然后 `NULL`.
|
||||
- 与 `NULLS FIRST` 修饰符:第一 `NULL`,然后 `NaN`,然后其他值。
|
||||
|
||||
### 示例 {#example}
|
||||
|
||||
对于表
|
||||
|
||||
``` text
|
||||
┌─x─┬────y─┐
|
||||
│ 1 │ ᴺᵁᴸᴸ │
|
||||
│ 2 │ 2 │
|
||||
│ 1 │ nan │
|
||||
│ 2 │ 2 │
|
||||
│ 3 │ 4 │
|
||||
│ 5 │ 6 │
|
||||
│ 6 │ nan │
|
||||
│ 7 │ ᴺᵁᴸᴸ │
|
||||
│ 6 │ 7 │
|
||||
│ 8 │ 9 │
|
||||
└───┴──────┘
|
||||
```
|
||||
|
||||
运行查询 `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST` 获得:
|
||||
|
||||
``` text
|
||||
┌─x─┬────y─┐
|
||||
│ 1 │ ᴺᵁᴸᴸ │
|
||||
│ 7 │ ᴺᵁᴸᴸ │
|
||||
│ 1 │ nan │
|
||||
│ 6 │ nan │
|
||||
│ 2 │ 2 │
|
||||
│ 2 │ 2 │
|
||||
│ 3 │ 4 │
|
||||
│ 5 │ 6 │
|
||||
│ 6 │ 7 │
|
||||
│ 8 │ 9 │
|
||||
└───┴──────┘
|
||||
```
|
||||
|
||||
当对浮点数进行排序时,Nan与其他值是分开的。 无论排序顺序如何,Nan都在最后。 换句话说,对于升序排序,它们被放置为好像它们比所有其他数字大,而对于降序排序,它们被放置为好像它们比其他数字小。
|
||||
|
||||
## 排序规则支持 {#collation-support}
|
||||
|
||||
对于按字符串值排序,可以指定排序规则(比较)。 示例: `ORDER BY SearchPhrase COLLATE 'tr'` -对于按关键字升序排序,使用土耳其字母,不区分大小写,假设字符串是UTF-8编码。 `COLLATE` 可以按顺序独立地指定或不按每个表达式。 如果 `ASC` 或 `DESC` 被指定, `COLLATE` 在它之后指定。 使用时 `COLLATE`,排序始终不区分大小写。
|
||||
|
||||
我们只建议使用 `COLLATE` 对于少量行的最终排序,因为排序与 `COLLATE` 比正常的按字节排序效率低。
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
更少的RAM使用,如果一个足够小 [LIMIT](../../../sql-reference/statements/select/limit.md) 除了指定 `ORDER BY`. 否则,所花费的内存量与用于排序的数据量成正比。 对于分布式查询处理,如果 [GROUP BY](../../../sql-reference/statements/select/group-by.md) 省略排序,在远程服务器上部分完成排序,并将结果合并到请求者服务器上。 这意味着对于分布式排序,要排序的数据量可以大于单个服务器上的内存量。
|
||||
|
||||
如果没有足够的RAM,则可以在外部存储器中执行排序(在磁盘上创建临时文件)。 使用设置 `max_bytes_before_external_sort` 为此目的。 如果将其设置为0(默认值),则禁用外部排序。 如果启用,则当要排序的数据量达到指定的字节数时,将对收集的数据进行排序并转储到临时文件中。 读取所有数据后,将合并所有已排序的文件并输出结果。 文件被写入到 `/var/lib/clickhouse/tmp/` 目录中的配置(默认情况下,但你可以使用 `tmp_path` 参数来更改此设置)。
|
||||
|
||||
运行查询可能占用的内存比 `max_bytes_before_external_sort`. 因此,此设置的值必须大大小于 `max_memory_usage`. 例如,如果您的服务器有128GB的RAM,并且您需要运行单个查询,请设置 `max_memory_usage` 到100GB,和 `max_bytes_before_external_sort` 至80GB。
|
||||
|
||||
外部排序的工作效率远远低于在RAM中进行排序。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/prewhere.md
|
23
docs/zh/sql-reference/statements/select/prewhere.md
Normal file
23
docs/zh/sql-reference/statements/select/prewhere.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: PREWHERE
|
||||
---
|
||||
|
||||
# PREWHERE条款 {#prewhere-clause}
|
||||
|
||||
Prewhere是更有效地应用过滤的优化。 默认情况下,即使在 `PREWHERE` 子句未显式指定。 它的工作原理是自动移动的一部分 [WHERE](../../../sql-reference/statements/select/where.md) 条件到prewhere阶段。 的作用 `PREWHERE` 子句只是控制这个优化,如果你认为你知道如何做得比默认情况下更好。
|
||||
|
||||
使用prewhere优化,首先只读取执行prewhere表达式所需的列。 然后读取运行其余查询所需的其他列,但只读取prewhere表达式所在的那些块 “true” 至少对于一些行。 如果有很多块,其中prewhere表达式是 “false” 对于所有行和prewhere需要比查询的其他部分更少的列,这通常允许从磁盘读取更少的数据以执行查询。
|
||||
|
||||
## 手动控制Prewhere {#controlling-prewhere-manually}
|
||||
|
||||
该条款具有相同的含义 `WHERE` 条款 区别在于从表中读取数据。 当手动控制 `PREWHERE` 对于查询中的少数列使用的过滤条件,但这些过滤条件提供了强大的数据过滤。 这减少了要读取的数据量。
|
||||
|
||||
查询可以同时指定 `PREWHERE` 和 `WHERE`. 在这种情况下, `PREWHERE` 先于 `WHERE`.
|
||||
|
||||
如果 `optimize_move_to_prewhere` 设置为0,启发式自动移动部分表达式 `WHERE` 到 `PREWHERE` 被禁用。
|
||||
|
||||
## 限制 {#limitations}
|
||||
|
||||
`PREWHERE` 只有从表支持 `*MergeTree` 家人
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/sample.md
|
114
docs/zh/sql-reference/statements/select/sample.md
Normal file
114
docs/zh/sql-reference/statements/select/sample.md
Normal file
@ -0,0 +1,114 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: SAMPLE
|
||||
---
|
||||
|
||||
# 示例子句 {#select-sample-clause}
|
||||
|
||||
该 `SAMPLE` 子句允许近似 `SELECT` 查询处理。
|
||||
|
||||
启用数据采样时,不会对所有数据执行查询,而只对特定部分数据(样本)执行查询。 例如,如果您需要计算所有访问的统计信息,只需对所有访问的1/10分数执行查询,然后将结果乘以10即可。
|
||||
|
||||
近似查询处理在以下情况下可能很有用:
|
||||
|
||||
- 当你有严格的时间requirements(如\<100ms),但你不能证明额外的硬件资源来满足他们的成本。
|
||||
- 当您的原始数据不准确时,所以近似不会明显降低质量。
|
||||
- 业务需求的目标是近似结果(为了成本效益,或者向高级用户推销确切结果)。
|
||||
|
||||
!!! note "注"
|
||||
您只能使用采样中的表 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 家庭,并且只有在表创建过程中指定了采样表达式(请参阅 [MergeTree引擎](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)).
|
||||
|
||||
下面列出了数据采样的功能:
|
||||
|
||||
- 数据采样是一种确定性机制。 同样的结果 `SELECT .. SAMPLE` 查询始终是相同的。
|
||||
- 对于不同的表,采样工作始终如一。 对于具有单个采样键的表,具有相同系数的采样总是选择相同的可能数据子集。 例如,用户Id的示例采用来自不同表的所有可能的用户Id的相同子集的行。 这意味着您可以在子查询中使用示例 [IN](../../../sql-reference/operators/in.md) 条款 此外,您可以使用 [JOIN](../../../sql-reference/statements/select/join.md) 条款
|
||||
- 采样允许从磁盘读取更少的数据。 请注意,您必须正确指定采样键。 有关详细信息,请参阅 [创建MergeTree表](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table).
|
||||
|
||||
为 `SAMPLE` 子句支持以下语法:
|
||||
|
||||
| SAMPLE Clause Syntax | 产品描述 |
|
||||
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `SAMPLE k` | 这里 `k` 是从0到1的数字。</br>查询执行于 `k` 数据的分数。 例如, `SAMPLE 0.1` 对10%的数据运行查询。 [碌莽禄more拢more](#select-sample-k) |
|
||||
| `SAMPLE n` | 这里 `n` 是足够大的整数。</br>该查询是在至少一个样本上执行的 `n` 行(但不超过这个)。 例如, `SAMPLE 10000000` 在至少10,000,000行上运行查询。 [碌莽禄more拢more](#select-sample-n) |
|
||||
| `SAMPLE k OFFSET m` | 这里 `k` 和 `m` 是从0到1的数字。</br>查询在以下示例上执行 `k` 数据的分数。 用于采样的数据由以下偏移 `m` 分数。 [碌莽禄more拢more](#select-sample-offset) |
|
||||
|
||||
## SAMPLE K {#select-sample-k}
|
||||
|
||||
这里 `k` 从0到1的数字(支持小数和小数表示法)。 例如, `SAMPLE 1/2` 或 `SAMPLE 0.5`.
|
||||
|
||||
在一个 `SAMPLE k` 子句,样品是从 `k` 数据的分数。 示例如下所示:
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
Title,
|
||||
count() * 10 AS PageViews
|
||||
FROM hits_distributed
|
||||
SAMPLE 0.1
|
||||
WHERE
|
||||
CounterID = 34
|
||||
GROUP BY Title
|
||||
ORDER BY PageViews DESC LIMIT 1000
|
||||
```
|
||||
|
||||
在此示例中,对0.1(10%)数据的样本执行查询。 聚合函数的值不会自动修正,因此要获得近似结果,值 `count()` 手动乘以10。
|
||||
|
||||
## SAMPLE N {#select-sample-n}
|
||||
|
||||
这里 `n` 是足够大的整数。 例如, `SAMPLE 10000000`.
|
||||
|
||||
在这种情况下,查询在至少一个样本上执行 `n` 行(但不超过这个)。 例如, `SAMPLE 10000000` 在至少10,000,000行上运行查询。
|
||||
|
||||
由于数据读取的最小单位是一个颗粒(其大小由 `index_granularity` 设置),是有意义的设置一个样品,其大小远大于颗粒。
|
||||
|
||||
使用时 `SAMPLE n` 子句,你不知道处理了哪些数据的相对百分比。 所以你不知道聚合函数应该乘以的系数。 使用 `_sample_factor` 虚拟列得到近似结果。
|
||||
|
||||
该 `_sample_factor` 列包含动态计算的相对系数。 当您执行以下操作时,将自动创建此列 [创建](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 具有指定采样键的表。 的使用示例 `_sample_factor` 列如下所示。
|
||||
|
||||
让我们考虑表 `visits`,其中包含有关网站访问的统计信息。 第一个示例演示如何计算页面浏览量:
|
||||
|
||||
``` sql
|
||||
SELECT sum(PageViews * _sample_factor)
|
||||
FROM visits
|
||||
SAMPLE 10000000
|
||||
```
|
||||
|
||||
下一个示例演示如何计算访问总数:
|
||||
|
||||
``` sql
|
||||
SELECT sum(_sample_factor)
|
||||
FROM visits
|
||||
SAMPLE 10000000
|
||||
```
|
||||
|
||||
下面的示例显示了如何计算平均会话持续时间。 请注意,您不需要使用相对系数来计算平均值。
|
||||
|
||||
``` sql
|
||||
SELECT avg(Duration)
|
||||
FROM visits
|
||||
SAMPLE 10000000
|
||||
```
|
||||
|
||||
## SAMPLE K OFFSET M {#select-sample-offset}
|
||||
|
||||
这里 `k` 和 `m` 是从0到1的数字。 示例如下所示。
|
||||
|
||||
**示例1**
|
||||
|
||||
``` sql
|
||||
SAMPLE 1/10
|
||||
```
|
||||
|
||||
在此示例中,示例是所有数据的十分之一:
|
||||
|
||||
`[++------------]`
|
||||
|
||||
**示例2**
|
||||
|
||||
``` sql
|
||||
SAMPLE 1/10 OFFSET 1/2
|
||||
```
|
||||
|
||||
这里,从数据的后半部分取出10%的样本。
|
||||
|
||||
`[------++------]`
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/union-all.md
|
36
docs/zh/sql-reference/statements/select/union-all.md
Normal file
36
docs/zh/sql-reference/statements/select/union-all.md
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: UNION ALL
|
||||
---
|
||||
|
||||
# UNION ALL条款 {#union-all-clause}
|
||||
|
||||
您可以使用 `UNION ALL` 结合任意数量的 `SELECT` 通过扩展其结果进行查询。 示例:
|
||||
|
||||
``` sql
|
||||
SELECT CounterID, 1 AS table, toInt64(count()) AS c
|
||||
FROM test.hits
|
||||
GROUP BY CounterID
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT CounterID, 2 AS table, sum(Sign) AS c
|
||||
FROM test.visits
|
||||
GROUP BY CounterID
|
||||
HAVING c > 0
|
||||
```
|
||||
|
||||
结果列通过它们的索引进行匹配(在内部的顺序 `SELECT`). 如果列名称不匹配,则从第一个查询中获取最终结果的名称。
|
||||
|
||||
对联合执行类型转换。 例如,如果合并的两个查询具有相同的字段与非-`Nullable` 和 `Nullable` 从兼容类型的类型,由此产生的 `UNION ALL` 有一个 `Nullable` 类型字段。
|
||||
|
||||
属于以下部分的查询 `UNION ALL` 不能用圆括号括起来。 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 和 [LIMIT](../../../sql-reference/statements/select/limit.md) 应用于单独的查询,而不是最终结果。 如果您需要将转换应用于最终结果,则可以将所有查询 `UNION ALL` 在子查询中 [FROM](../../../sql-reference/statements/select/from.md) 条款
|
||||
|
||||
## 限制 {#limitations}
|
||||
|
||||
只有 `UNION ALL` 支持。 定期的 `UNION` (`UNION DISTINCT`)不支持。 如果你需要 `UNION DISTINCT`,你可以写 `SELECT DISTINCT` 从包含 `UNION ALL`.
|
||||
|
||||
## 实施细节 {#implementation-details}
|
||||
|
||||
属于以下部分的查询 `UNION ALL` 可以同时运行,并且它们的结果可以混合在一起。
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/where.md
|
16
docs/zh/sql-reference/statements/select/where.md
Normal file
16
docs/zh/sql-reference/statements/select/where.md
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: WHERE
|
||||
---
|
||||
|
||||
# WHERE条款 {#select-where}
|
||||
|
||||
`WHERE` 子句允许过滤来自 [FROM](../../../sql-reference/statements/select/from.md) 的条款 `SELECT`.
|
||||
|
||||
如果有一个 `WHERE` 子句,它必须包含一个表达式与 `UInt8` 类型。 这通常是一个带有比较和逻辑运算符的表达式。 此表达式计算结果为0的行将从进一步的转换或结果中解释出来。
|
||||
|
||||
`WHERE` 如果基础表引擎支持,则根据使用索引和分区修剪的能力评估expression。
|
||||
|
||||
!!! note "注"
|
||||
有一个叫做过滤优化 [去哪里](../../../sql-reference/statements/select/prewhere.md).
|
@ -1 +0,0 @@
|
||||
../../../../en/sql-reference/statements/select/with.md
|
81
docs/zh/sql-reference/statements/select/with.md
Normal file
81
docs/zh/sql-reference/statements/select/with.md
Normal file
@ -0,0 +1,81 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
|
||||
toc_title: WITH
|
||||
---
|
||||
|
||||
# WITH条款 {#with-clause}
|
||||
|
||||
本节提供对公共表表达式的支持 ([CTE](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL)),所以结果 `WITH` 子句可以在其余部分中使用 `SELECT` 查询。
|
||||
|
||||
## 限制 {#limitations}
|
||||
|
||||
1. 不支持递归查询。
|
||||
2. 当在section中使用子查询时,它的结果应该是只有一行的标量。
|
||||
3. Expression的结果在子查询中不可用。
|
||||
|
||||
## 例 {#examples}
|
||||
|
||||
**示例1:** 使用常量表达式作为 “variable”
|
||||
|
||||
``` sql
|
||||
WITH '2019-08-01 15:23:00' as ts_upper_bound
|
||||
SELECT *
|
||||
FROM hits
|
||||
WHERE
|
||||
EventDate = toDate(ts_upper_bound) AND
|
||||
EventTime <= ts_upper_bound
|
||||
```
|
||||
|
||||
**示例2:** 从SELECT子句列表中逐出sum(bytes)表达式结果
|
||||
|
||||
``` sql
|
||||
WITH sum(bytes) as s
|
||||
SELECT
|
||||
formatReadableSize(s),
|
||||
table
|
||||
FROM system.parts
|
||||
GROUP BY table
|
||||
ORDER BY s
|
||||
```
|
||||
|
||||
**例3:** 使用标量子查询的结果
|
||||
|
||||
``` sql
|
||||
/* this example would return TOP 10 of most huge tables */
|
||||
WITH
|
||||
(
|
||||
SELECT sum(bytes)
|
||||
FROM system.parts
|
||||
WHERE active
|
||||
) AS total_disk_usage
|
||||
SELECT
|
||||
(sum(bytes) / total_disk_usage) * 100 AS table_disk_usage,
|
||||
table
|
||||
FROM system.parts
|
||||
GROUP BY table
|
||||
ORDER BY table_disk_usage DESC
|
||||
LIMIT 10
|
||||
```
|
||||
|
||||
**例4:** 在子查询中重用表达式
|
||||
|
||||
作为子查询中表达式使用的当前限制的解决方法,您可以复制它。
|
||||
|
||||
``` sql
|
||||
WITH ['hello'] AS hello
|
||||
SELECT
|
||||
hello,
|
||||
*
|
||||
FROM
|
||||
(
|
||||
WITH ['hello'] AS hello
|
||||
SELECT hello
|
||||
)
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─hello─────┬─hello─────┐
|
||||
│ ['hello'] │ ['hello'] │
|
||||
└───────────┴───────────┘
|
||||
```
|
@ -1,19 +1,17 @@
|
||||
---
|
||||
machine_translated: true
|
||||
machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd
|
||||
toc_priority: 38
|
||||
toc_title: SHOW
|
||||
---
|
||||
|
||||
# 显示查询 {#show-queries}
|
||||
# SHOW 查询 {#show-queries}
|
||||
|
||||
## SHOW CREATE TABLE {#show-create-table}
|
||||
|
||||
``` sql
|
||||
SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format]
|
||||
```
|
||||
返回单个字符串类型的 ‘statement’列,其中只包含了一个值 - 用来创建指定对象的 `CREATE` 语句。
|
||||
|
||||
返回单 `String`-类型 ‘statement’ column, which contains a single value – the `CREATE` 用于创建指定对象的查询。
|
||||
|
||||
## SHOW DATABASES {#show-databases}
|
||||
|
||||
@ -21,8 +19,7 @@ SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [F
|
||||
SHOW DATABASES [INTO OUTFILE filename] [FORMAT format]
|
||||
```
|
||||
|
||||
打印所有数据库的列表。
|
||||
这个查询是相同的 `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`.
|
||||
打印所有的数据库列表,该查询等同于 `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`
|
||||
|
||||
## SHOW PROCESSLIST {#show-processlist}
|
||||
|
||||
@ -30,11 +27,13 @@ SHOW DATABASES [INTO OUTFILE filename] [FORMAT format]
|
||||
SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format]
|
||||
```
|
||||
|
||||
输出的内容 [系统。流程](../../operations/system-tables.md#system_tables-processes) 表,包含目前正在处理的查询列表,除了 `SHOW PROCESSLIST` 查询。
|
||||
输出 [system.processes](../../operations/system-tables/processes.md#system_tables-processes)表的内容,包含有当前正在处理的请求列表,除了 `SHOW PROCESSLIST`查询。
|
||||
|
||||
该 `SELECT * FROM system.processes` 查询返回有关所有当前查询的数据。
|
||||
|
||||
提示(在控制台中执行):
|
||||
`SELECT * FROM system.processes` 查询返回和当前请求相关的所有数据
|
||||
|
||||
|
||||
提示 (在控制台执行):
|
||||
|
||||
``` bash
|
||||
$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'"
|
||||
@ -42,15 +41,15 @@ $ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'"
|
||||
|
||||
## SHOW TABLES {#show-tables}
|
||||
|
||||
显示表的列表。
|
||||
显示表的清单
|
||||
|
||||
``` sql
|
||||
SHOW [TEMPORARY] TABLES [{FROM | IN} <db>] [LIKE '<pattern>' | WHERE expr] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
|
||||
```
|
||||
|
||||
如果 `FROM` 如果未指定子句,则查询返回当前数据库中的表列表。
|
||||
如果未使用 `FROM` 字句,该查询返回当前数据库的所有表清单
|
||||
|
||||
你可以得到相同的结果 `SHOW TABLES` 通过以下方式进行查询:
|
||||
可以用下面的方式获得和 `SHOW TABLES`一样的结果:
|
||||
|
||||
``` sql
|
||||
SELECT name FROM system.tables WHERE database = <db> [AND name LIKE <pattern>] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
|
||||
@ -58,7 +57,7 @@ SELECT name FROM system.tables WHERE database = <db> [AND name LIKE <pattern>] [
|
||||
|
||||
**示例**
|
||||
|
||||
下面的查询从表的列表中选择前两行 `system` 数据库,其名称包含 `co`.
|
||||
下列查询获取最前面的2个位于`system`库中且表名包含 `co`的表。
|
||||
|
||||
``` sql
|
||||
SHOW TABLES FROM system LIKE '%co%' LIMIT 2
|
||||
@ -73,15 +72,15 @@ SHOW TABLES FROM system LIKE '%co%' LIMIT 2
|
||||
|
||||
## SHOW DICTIONARIES {#show-dictionaries}
|
||||
|
||||
显示列表 [外部字典](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md).
|
||||
以列表形式显示 [外部字典](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md).
|
||||
|
||||
``` sql
|
||||
SHOW DICTIONARIES [FROM <db>] [LIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
|
||||
```
|
||||
|
||||
如果 `FROM` 如果未指定子句,则查询从当前数据库返回字典列表。
|
||||
如果 `FROM`字句没有指定,返回当前数据库的字典列表
|
||||
|
||||
你可以得到相同的结果 `SHOW DICTIONARIES` 通过以下方式进行查询:
|
||||
可以通过下面的查询获取和 `SHOW DICTIONARIES`相同的结果:
|
||||
|
||||
``` sql
|
||||
SELECT name FROM system.dictionaries WHERE database = <db> [AND name LIKE <pattern>] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
|
||||
@ -89,7 +88,7 @@ SELECT name FROM system.dictionaries WHERE database = <db> [AND name LIKE <patte
|
||||
|
||||
**示例**
|
||||
|
||||
下面的查询从表的列表中选择前两行 `system` 数据库,其名称包含 `reg`.
|
||||
下列查询获取最前面的2个位于 `system`库中且名称包含 `reg`的字典表。
|
||||
|
||||
``` sql
|
||||
SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2
|
||||
@ -104,7 +103,7 @@ SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2
|
||||
|
||||
## SHOW GRANTS {#show-grants-statement}
|
||||
|
||||
显示用户的权限。
|
||||
显示用户的权限
|
||||
|
||||
### 语法 {#show-grants-syntax}
|
||||
|
||||
@ -112,13 +111,13 @@ SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2
|
||||
SHOW GRANTS [FOR user]
|
||||
```
|
||||
|
||||
如果未指定user,则查询返回当前用户的权限。
|
||||
如果未指定用户,输出当前用户的权限
|
||||
|
||||
## SHOW CREATE USER {#show-create-user-statement}
|
||||
|
||||
显示了在使用的参数 [用户创建](create.md#create-user-statement).
|
||||
显示 [user creation](../../sql-reference/statements/create.md#create-user-statement)用到的参数。
|
||||
|
||||
`SHOW CREATE USER` 不输出用户密码。
|
||||
`SHOW CREATE USER` 不会输出用户的密码信息
|
||||
|
||||
### 语法 {#show-create-user-syntax}
|
||||
|
||||
@ -128,7 +127,7 @@ SHOW CREATE USER [name | CURRENT_USER]
|
||||
|
||||
## SHOW CREATE ROLE {#show-create-role-statement}
|
||||
|
||||
显示了在使用的参数 [角色创建](create.md#create-role-statement)
|
||||
显示 [role creation](../../sql-reference/statements/create.md#create-role-statement) 中用到的参数。
|
||||
|
||||
### 语法 {#show-create-role-syntax}
|
||||
|
||||
@ -138,7 +137,7 @@ SHOW CREATE ROLE name
|
||||
|
||||
## SHOW CREATE ROW POLICY {#show-create-row-policy-statement}
|
||||
|
||||
显示了在使用的参数 [创建行策略](create.md#create-row-policy-statement)
|
||||
显示 [row policy creation](../../sql-reference/statements/create.md#create-row-policy-statement)中用到的参数
|
||||
|
||||
### 语法 {#show-create-row-policy-syntax}
|
||||
|
||||
@ -148,7 +147,7 @@ SHOW CREATE [ROW] POLICY name ON [database.]table
|
||||
|
||||
## SHOW CREATE QUOTA {#show-create-quota-statement}
|
||||
|
||||
显示了在使用的参数 [创建配额](create.md#create-quota-statement)
|
||||
显示 [quota creation](../../sql-reference/statements/create.md#create-quota-statement)中用到的参数
|
||||
|
||||
### 语法 {#show-create-row-policy-syntax}
|
||||
|
||||
@ -158,7 +157,7 @@ SHOW CREATE QUOTA [name | CURRENT]
|
||||
|
||||
## SHOW CREATE SETTINGS PROFILE {#show-create-settings-profile-statement}
|
||||
|
||||
显示了在使用的参数 [设置配置文件创建](create.md#create-settings-profile-statement)
|
||||
显示 [settings profile creation](../../sql-reference/statements/create.md#create-settings-profile-statement)中用到的参数
|
||||
|
||||
### 语法 {#show-create-row-policy-syntax}
|
||||
|
||||
@ -166,4 +165,4 @@ SHOW CREATE QUOTA [name | CURRENT]
|
||||
SHOW CREATE [SETTINGS] PROFILE name
|
||||
```
|
||||
|
||||
[原始文章](https://clickhouse.tech/docs/en/query_language/show/) <!--hide-->
|
||||
[原始文档](https://clickhouse.tech/docs/en/query_language/show/) <!--hide-->
|
||||
|
@ -38,7 +38,7 @@ CH支持SQL风格或C语言风格的注释:
|
||||
- 在某些流行的RDBMS中被实现的关键字,例如,`DateTime` 和 `datetime`是一样的
|
||||
|
||||
|
||||
你可以在系统表 [system.data_type_families](../operations/system-tables.md#system_tables-data_type_families) 中检查某个数据类型的名称是否是大小写敏感型。
|
||||
你可以在系统表 [system.data_type_families](../operations/system-tables/data_type_families.md#system_tables-data_type_families) 中检查某个数据类型的名称是否是大小写敏感型。
|
||||
|
||||
和标准SQL相反,所有其它的关键字都是 **大小写敏感的**,包括函数名称。
|
||||
In contrast to standard SQL, all other keywords (including functions names) are **case-sensitive**.
|
||||
|
@ -398,6 +398,7 @@ private:
|
||||
{ TokenType::GreaterOrEquals, Replxx::Color::INTENSE },
|
||||
{ TokenType::Concatenation, Replxx::Color::INTENSE },
|
||||
{ TokenType::At, Replxx::Color::INTENSE },
|
||||
{ TokenType::DoubleAt, Replxx::Color::MAGENTA },
|
||||
|
||||
{ TokenType::EndOfStream, Replxx::Color::DEFAULT },
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <Common/Elf.h>
|
||||
#include <Common/Exception.h>
|
||||
#include <common/unaligned.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -135,7 +136,7 @@ String Elf::getBuildID(const char * nhdr_pos, size_t size)
|
||||
|
||||
while (nhdr_pos < nhdr_end)
|
||||
{
|
||||
const ElfNhdr & nhdr = *reinterpret_cast<const ElfNhdr *>(nhdr_pos);
|
||||
ElfNhdr nhdr = unalignedLoad<ElfNhdr>(nhdr_pos);
|
||||
|
||||
nhdr_pos += sizeof(ElfNhdr) + nhdr.n_namesz;
|
||||
if (nhdr.n_type == NT_GNU_BUILD_ID)
|
||||
|
@ -493,8 +493,9 @@ namespace ErrorCodes
|
||||
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN = 524;
|
||||
extern const int INCORRECT_DISK_INDEX = 525;
|
||||
extern const int UNKNOWN_VOLUME_TYPE = 526;
|
||||
extern const int CASSANDRA_INTERNAL_ERROR = 527;
|
||||
extern const int NOT_A_LEADER = 528;
|
||||
extern const int NO_SUITABLE_FUNCTION_IMPLEMENTATION = 527;
|
||||
extern const int CASSANDRA_INTERNAL_ERROR = 528;
|
||||
extern const int NOT_A_LEADER = 529;
|
||||
|
||||
extern const int KEEPER_EXCEPTION = 999;
|
||||
extern const int POCO_EXCEPTION = 1000;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#if defined(__ELF__) && !defined(__FreeBSD__)
|
||||
|
||||
#include <Common/SymbolIndex.h>
|
||||
#include <Common/hex.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
@ -289,18 +290,24 @@ bool searchAndCollectSymbolsFromELFSymbolTable(
|
||||
|
||||
void collectSymbolsFromELF(dl_phdr_info * info,
|
||||
std::vector<SymbolIndex::Symbol> & symbols,
|
||||
std::vector<SymbolIndex::Object> & objects)
|
||||
std::vector<SymbolIndex::Object> & objects,
|
||||
String & build_id)
|
||||
{
|
||||
/// MSan does not know that the program segments in memory are initialized.
|
||||
__msan_unpoison_string(info->dlpi_name);
|
||||
|
||||
std::string object_name = info->dlpi_name;
|
||||
|
||||
String our_build_id = getBuildIDFromProgramHeaders(info);
|
||||
|
||||
/// If the name is empty - it's main executable.
|
||||
/// Find a elf file for the main executable.
|
||||
|
||||
if (object_name.empty())
|
||||
{
|
||||
object_name = "/proc/self/exe";
|
||||
build_id = our_build_id;
|
||||
}
|
||||
|
||||
std::error_code ec;
|
||||
std::filesystem::path canonical_path = std::filesystem::canonical(object_name, ec);
|
||||
@ -314,7 +321,6 @@ void collectSymbolsFromELF(dl_phdr_info * info,
|
||||
object_name = std::filesystem::exists(debug_info_path) ? debug_info_path : canonical_path;
|
||||
|
||||
/// But we have to compare Build ID to check that debug info corresponds to the same executable.
|
||||
String our_build_id = getBuildIDFromProgramHeaders(info);
|
||||
|
||||
SymbolIndex::Object object;
|
||||
object.elf = std::make_unique<Elf>(object_name);
|
||||
@ -359,7 +365,7 @@ int collectSymbols(dl_phdr_info * info, size_t, void * data_ptr)
|
||||
SymbolIndex::Data & data = *reinterpret_cast<SymbolIndex::Data *>(data_ptr);
|
||||
|
||||
collectSymbolsFromProgramHeaders(info, data.symbols);
|
||||
collectSymbolsFromELF(info, data.symbols, data.objects);
|
||||
collectSymbolsFromELF(info, data.symbols, data.objects, data.build_id);
|
||||
|
||||
/* Continue iterations */
|
||||
return 0;
|
||||
@ -412,6 +418,22 @@ const SymbolIndex::Object * SymbolIndex::findObject(const void * address) const
|
||||
return find(address, data.objects);
|
||||
}
|
||||
|
||||
String SymbolIndex::getBuildIDHex() const
|
||||
{
|
||||
String build_id_binary = getBuildID();
|
||||
String build_id_hex;
|
||||
build_id_hex.resize(build_id_binary.size() * 2);
|
||||
|
||||
char * pos = build_id_hex.data();
|
||||
for (auto c : build_id_binary)
|
||||
{
|
||||
writeHexByteUppercase(c, pos);
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
return build_id_hex;
|
||||
}
|
||||
|
||||
SymbolIndex & SymbolIndex::instance()
|
||||
{
|
||||
static SymbolIndex instance;
|
||||
|
@ -45,10 +45,15 @@ public:
|
||||
const std::vector<Symbol> & symbols() const { return data.symbols; }
|
||||
const std::vector<Object> & objects() const { return data.objects; }
|
||||
|
||||
/// The BuildID that is generated by compiler.
|
||||
String getBuildID() const { return data.build_id; }
|
||||
String getBuildIDHex() const;
|
||||
|
||||
struct Data
|
||||
{
|
||||
std::vector<Symbol> symbols;
|
||||
std::vector<Object> objects;
|
||||
String build_id;
|
||||
};
|
||||
private:
|
||||
Data data;
|
||||
|
@ -134,3 +134,14 @@ inline __int128 exp10_i128(int x)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// intExp10 returning the type T.
|
||||
template <typename T>
|
||||
inline T intExp10OfSize(int x)
|
||||
{
|
||||
if constexpr (sizeof(T) <= 8)
|
||||
return intExp10(x);
|
||||
else
|
||||
return common::exp10_i128(x);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void CompressionCodecFactory::registerCompressionCodecWithType(
|
||||
|
||||
if (byte_code)
|
||||
if (!family_code_with_codec.emplace(*byte_code, creator).second)
|
||||
throw Exception("CompressionCodecFactory: the codec family name '" + family_name + "' is not unique", ErrorCodes::LOGICAL_ERROR);
|
||||
throw Exception("CompressionCodecFactory: the codec family code '" + std::to_string(*byte_code) + "' is not unique", ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
|
||||
void CompressionCodecFactory::registerCompressionCodec(const String & family_name, std::optional<uint8_t> byte_code, Creator creator)
|
||||
|
@ -233,6 +233,10 @@ public:
|
||||
/** Size of the message in bytes including message length part (4 bytes) */
|
||||
virtual Int32 size() const = 0;
|
||||
|
||||
ISerializable() = default;
|
||||
|
||||
ISerializable(const ISerializable &) = default;
|
||||
|
||||
virtual ~ISerializable() = default;
|
||||
};
|
||||
|
||||
|
@ -377,6 +377,7 @@ struct Settings : public SettingsCollection<Settings>
|
||||
M(SettingBool, allow_nondeterministic_mutations, false, "Allow non-deterministic functions in ALTER UPDATE/ALTER DELETE statements", 0) \
|
||||
M(SettingSeconds, lock_acquire_timeout, DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC, "How long locking request should wait before failing", 0) \
|
||||
M(SettingBool, materialize_ttl_after_modify, true, "Apply TTL for old data, after ALTER MODIFY TTL query", 0) \
|
||||
M(SettingString, function_implementation, "", "Choose function implementation for specific target or variant (experimental). If empty enable all of them.", 0) \
|
||||
\
|
||||
M(SettingBool, allow_experimental_geo_types, false, "Allow geo data types such as Point, Ring, Polygon, MultiPolygon", 0) \
|
||||
M(SettingBool, data_type_default_nullable, false, "Data types without NULL or NOT NULL will make Nullable", 0) \
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user