> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> `Dictionary` エンジンは、Dictionary のデータを ClickHouse テーブルとして表示します。

# Dictionary テーブルエンジン

`Dictionary` エンジンは、[dictionary](/ja/reference/statements/create/dictionary) のデータを ClickHouse テーブルとして表示します。

<div id="example">
  ## 例
</div>

例として、次のような設定の `products` Dictionary を考えます。

```xml theme={null}
<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>
```

Dictionary データをクエリする:

```sql theme={null}
SELECT
    name,
    type,
    key,
    attribute.names,
    attribute.types,
    bytes_allocated,
    element_count,
    source
FROM system.dictionaries
WHERE name = 'products'
```

```text theme={null}
┌─name─────┬─type─┬─key────┬─attribute.names─┬─attribute.types─┬─bytes_allocated─┬─element_count─┬─source──────────┐
│ products │ Flat │ UInt64 │ ['title']       │ ['String']      │        23065376 │        175032 │ ODBC: .products │
└──────────┴──────┴────────┴─────────────────┴─────────────────┴─────────────────┴───────────────┴─────────────────┘
```

このフォーマットでDictionaryのデータを取得するには、[dictGet\*](/ja/reference/functions/regular-functions/ext-dict-functions) 関数を使用できます。

生データを取得する必要がある場合や、`JOIN` 操作を行う場合、この表示方法はあまり役に立ちません。こうした場合は、Dictionaryのデータをテーブルとして表示する `Dictionary` エンジンを使用できます。

構文:

```sql theme={null}
CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)`
```

使用例:

```sql theme={null}
CREATE TABLE products (product_id UInt64, title String) ENGINE = Dictionary(products);
```

OK

テーブルの内容を見てみましょう。

```sql theme={null}
SELECT * FROM products LIMIT 1;
```

```text theme={null}
┌────product_id─┬─title───────────┐
│        152689 │ Some item       │
└───────────────┴─────────────────┘
```

**関連項目**

* [Dictionary 関数](/ja/reference/functions/table-functions/dictionary)
