Help wanted!
The following content of this documentation page has been machine-translated. But unlike other websites, it is not done on the fly. This translated text lives on GitHub repository alongside main ClickHouse codebase and waits for fellow native speakers to make it more human-readable. You can also use the original English version as a reference.
辞書
その Dictionary
エンジンは表示します 辞書 ClickHouseテーブルとしてのデータ。
例として、の辞書を考えてみましょう products
以下の構成で:
<dictionaries>
<dictionary>
<name>products</name>
<source>
<odbc>
<table>products</table>
<connection_string>DSN=some-db-server</connection_string>
</odbc>
</source>
<lifetime>
<min>300</min>
<max>360</max>
</lifetime>
<layout>
<flat/>
</layout>
<structure>
<id>
<name>product_id</name>
</id>
<attribute>
<name>title</name>
<type>String</type>
<null_value></null_value>
</attribute>
</structure>
</dictionary>
</dictionaries>
辞書データの照会:
SELECT
name,
type,
key,
attribute.names,
attribute.types,
bytes_allocated,
element_count,
source
FROM system.dictionaries
WHERE name = 'products'
┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐
│ products │ Flat │ UInt64 │ ['title'] │ ['String'] │ 23065376 │ 175032 │ ODBC: .products │
└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘
を使用することができます dictGet* この形式の辞書データを取得する関数。
このビューは、生データを取得する必要がある場合や、 JOIN
作戦だ これらのケースでは、 Dictionary
ディクショナリデータをテーブルに表示するエンジン。
構文:
CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)`
使用例:
create table products (product_id UInt64, title String) Engine = Dictionary(products);
Ok
テーブルにあるものを見てみなさい。
select * from products limit 1;
┌────product_id─┬─title───────────┐
│ 152689 │ Some item │
└───────────────┴─────────────────┘