ClickHouse/docs/ja/engines/table_engines/special/dictionary.md
2020-04-04 12:15:31 +03:00

3.1 KiB

machine_translated machine_translated_rev toc_priority toc_title
true d734a8e46d 35 辞書

辞書

その Dictionary エンジンは表示します 辞書 クリックハウス表としてのデータ。

例として、次の辞書を考えてみましょう 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* この形式の辞書データを取得する関数です。

このビューがない便だが、rawデータ、または行う場合には、 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       │
└───────────────┴─────────────────┘

元の記事