2021-05-19 13:19:49 +00:00
---
toc_priority: 54
toc_title: dictionary function
---
# dictionary {#dictionary-function}
2021-05-26 17:12:40 +00:00
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.
2021-05-19 13:19:49 +00:00
**Syntax**
``` sql
dictionary('dict')
```
**Arguments**
- `dict` — A dictionary name. [String ](../../sql-reference/data-types/string.md ).
**Returned value**
A ClickHouse table.
**Example**
2021-05-26 17:12:30 +00:00
Input table `dictionary_source_table` :
2021-05-19 13:19:49 +00:00
``` text
┌─id─┬─value─┐
│ 0 │ 0 │
│ 1 │ 1 │
└────┴───────┘
```
Create a dictionary:
``` sql
2021-05-26 17:13:05 +00:00
CREATE DICTIONARY new_dictionary(id UInt64, value UInt64 DEFAULT 0) PRIMARY KEY id
2021-05-26 17:12:20 +00:00
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'dictionary_source_table')) LAYOUT(DIRECT());
2021-05-19 13:19:49 +00:00
```
Query:
``` sql
2021-05-26 17:12:10 +00:00
SELECT * FROM dictionary('new_dictionary');
2021-05-19 13:19:49 +00:00
```
Result:
``` text
┌─id─┬─value─┐
│ 0 │ 0 │
│ 1 │ 1 │
└────┴───────┘
```
**See Also**
- [Dictionary engine ](../../engines/table-engines/special/dictionary.md#dictionary )