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);좋습니다.
테이블에 어떤 데이터가 들어 있는지 살펴보겠습니다.
SELECT * FROM products LIMIT 1;┌────product_id─┬─title───────────┐
│ 152689 │ Some item │
└───────────────┴─────────────────┘관련 항목