Skip to main content

How to Create a ClickHouse Dictionary with String Keys and Values

Learn how to create a ClickHouse dictionary using string keys and values from a MergeTree table as the source, with examples of setup and usage.

Question

How to create a ClickHouse dictionary using string keys and string values from a MergeTree table source

Answer

  • Create the source table for the dictionary
  • Insert rows
  • Create dictionary with key/value both as String
  • Test the dictionary

You can also use dictGet function to retrieve values from it such as:

Response:

More details - https://clickhouse.com/docs/en/sql-reference/functions/ext-dict-functions

· One min read