mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 19:45:11 +00:00
60 lines
1.2 KiB
Markdown
60 lines
1.2 KiB
Markdown
---
|
|
slug: /en/sql-reference/table-functions/dictionary
|
|
sidebar_position: 54
|
|
sidebar_label: dictionary function
|
|
title: dictionary
|
|
---
|
|
|
|
Displays the [dictionary](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md) data as a ClickHouse table. Works the same way as [Dictionary](../../engines/table-engines/special/dictionary.md) engine.
|
|
|
|
**Syntax**
|
|
|
|
``` sql
|
|
dictionary('dict')
|
|
```
|
|
|
|
**Arguments**
|
|
|
|
- `dict` — A dictionary name. [String](../../sql-reference/data-types/string.md).
|
|
|
|
**Returned value**
|
|
|
|
A ClickHouse table.
|
|
|
|
**Example**
|
|
|
|
Input table `dictionary_source_table`:
|
|
|
|
``` text
|
|
┌─id─┬─value─┐
|
|
│ 0 │ 0 │
|
|
│ 1 │ 1 │
|
|
└────┴───────┘
|
|
```
|
|
|
|
Create a dictionary:
|
|
|
|
``` sql
|
|
CREATE DICTIONARY new_dictionary(id UInt64, value UInt64 DEFAULT 0) PRIMARY KEY id
|
|
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'dictionary_source_table')) LAYOUT(DIRECT());
|
|
```
|
|
|
|
Query:
|
|
|
|
``` sql
|
|
SELECT * FROM dictionary('new_dictionary');
|
|
```
|
|
|
|
Result:
|
|
|
|
``` text
|
|
┌─id─┬─value─┐
|
|
│ 0 │ 0 │
|
|
│ 1 │ 1 │
|
|
└────┴───────┘
|
|
```
|
|
|
|
**See Also**
|
|
|
|
- [Dictionary engine](../../engines/table-engines/special/dictionary.md#dictionary)
|