Skip to main content
A dictionary is a mapping (key -> attributes) that is convenient for various types of reference lists. ClickHouse supports special functions for working with dictionaries that can be used in queries. It is easier and more efficient to use dictionaries with functions than a JOIN with reference tables. Dictionaries can be created in two ways:

Creating a dictionary with a DDL query

Dictionaries can be created with DDL queries. This is the recommended method because with DDL created dictionaries:
  • No additional records are added to server configuration files.
  • Dictionaries can be used like first-class entities such as tables or views.
  • Data can be read directly, using familiar SELECT syntax rather than dictionary table functions. Note that when accessing a dictionary directly via a SELECT statement, cached dictionary will return only cached data, while for a non-cached dictionary it will return all the data that it stores.
  • Dictionaries can be easily renamed.

Syntax

Creating a dictionary with a configuration file

ClickHouse Cloud does not support creating dictionaries with configuration files. Use CREATE DICTIONARY instead.When creating a dictionary that reads from a ClickHouse table, include a dedicated user’s username and password in the SOURCE clause. That user needs SELECT permission on the source table. See the ClickHouse dictionary source example.
The dictionary configuration file has the following format:
You can configure any number of dictionaries in the same file.