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

3.3 KiB
Raw Blame History

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 │
└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘

شما می توانید از دیکته کردن* تابع برای دریافت داده های فرهنگ لغت در این فرمت.

این دیدگاه مفید نیست که شما نیاز به دریافت داده های خام, و یا در هنگام انجام یک 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       │
└───────────────┴─────────────────┘

مقاله اصلی