Skip to main content
Named collections provide a way to store collections of key-value pairs to be used to configure integrations with external sources. You can use named collections with dictionaries, tables, table functions, and object storage.
DDL-created named collections can be enabled on select ClickHouse Cloud services. Contact Support to confirm availability. Named collections defined in configuration files aren’t available because users can’t modify server configuration files in ClickHouse Cloud.
Named collections can be configured with DDL or in configuration files and are applied when ClickHouse starts. They simplify the creation of objects and the hiding of credentials from users without administrative access. The keys in a named collection must match the parameter names of the corresponding function, table engine, database, etc. In the examples below the parameter list is linked to for each type. Overriding a parameter stored in a named collection requires the SHOW NAMED COLLECTIONS SECRETS privilege on that collection, including when the parameter is marked OVERRIDABLE. Keys marked NOT OVERRIDABLE in SQL or overridable="false" in XML cannot be overridden. Adding a parameter that the collection does not store does not require this additional privilege. Aliases, such as addresses_expr for host, count as overrides of the stored parameter.
This check requires the privilege alone; it does not depend on the settings that control displaying secrets. The allow_named_collection_override_by_default setting is obsolete and has no effect. Dictionary sources follow the same rule. The privilege is checked when the dictionary is created, attached, or restored. When the dictionary is loaded, only keys marked NOT OVERRIDABLE are enforced.

Storing named collections in the system database

DDL example

In the above example:
  • key_1 can be overridden by users with SHOW NAMED COLLECTIONS SECRETS on the collection.
  • key_2 can never be overridden.
  • url can be overridden by users with SHOW NAMED COLLECTIONS SECRETS on the collection.

Permissions to create named collections with DDL

To manage named collections with DDL a user must have the named_collection_control privilege. This can be assigned by adding a file to /etc/clickhouse-server/users.d/. The example gives the user default both the access_management and named_collection_control privileges:
/etc/clickhouse-server/users.d/user_default.xml
In the above example the password_sha256_hex value is the hexadecimal representation of the SHA256 hash of the password. This configuration for the user default has the attribute replace=true as in the default configuration has a plain text password set, and it is not possible to have both plain text and sha256 hex passwords set for a user.
named_collection_control allows the user to create, alter and drop named collections, but not to read back the values that are already stored in them. That is a separate privilege, SHOW NAMED COLLECTIONS SECRETS, enabled by the show_named_collections_secrets setting. A user can only grant the privileges that they have themselves, so while show_named_collections_secrets is disabled, the user does not have the complete set of privileges and GRANT ALL ON *.* TO another_user WITH GRANT OPTION is rejected with (Missing permissions: SHOW NAMED COLLECTIONS SECRETS ON *).

Storage for named collections

Named collections can either be stored on local disk or in ZooKeeper/Keeper. By default local storage is used. They can also be stored using encryption with the same algorithms used for disk encryption, where aes_128_ctr is used by default. To configure named collections storage you need to specify a type. This can be either local or keeper/zookeeper. For encrypted storage, you can use local_encrypted or keeper_encrypted/zookeeper_encrypted. To use ZooKeeper/Keeper we also need to set up a path (path in ZooKeeper/Keeper, where named collections will be stored) to named_collections_storage section in configuration file. The following example uses encryption and ZooKeeper/Keeper:
An optional configuration parameter update_timeout_ms by default is equal to 5000. You can inspect the active storage type through system.server_settings and getServerSetting:
Changing the storage type requires a server restart; SYSTEM RELOAD CONFIG does not change the active backend.

Storing named collections in configuration files

XML example

/etc/clickhouse-server/config.d/named_collections.xml
In the above example:
  • key_1 can be overridden by users with SHOW NAMED COLLECTIONS SECRETS on the collection.
  • key_2 can never be overridden.
  • url can be overridden by users with SHOW NAMED COLLECTIONS SECRETS on the collection.

Modifying named collections

Named collections that are created with DDL queries can be altered or dropped with DDL. Named collections created with XML files can be managed by editing or deleting the corresponding XML.

Alter a DDL named collection

Change or add the keys key1 and key3 of the collection collection2 (this will not change the value of the overridable flag for those keys):
Change or add the key key1 and allow it to be always overridden:
Remove the key key2 from collection2:
Change or add the key key1 and delete the key key3 of the collection collection2:
To force a key to use the default settings for the overridable flag, you have to remove and re-add the key.

Drop the DDL named collection collection2:

Named collections for accessing S3

The description of parameters see s3 Table Function.

DDL example

XML example

s3() function and S3 Table named collection examples

Both of the following examples use the same named collection s3_mydata:

s3() function

The first argument to the s3() function above is the name of the collection, s3_mydata. Without named collections, the access key ID, secret, format, and URL would all be passed in every call to the s3() function.

S3 table

Named collections for accessing MySQL database

The description of parameters see mysql.

DDL example

XML example

mysql() function, MySQL table, MySQL database, and Dictionary named collection examples

The four following examples use the same named collection mymysql:

mysql() function

The named collection does not specify the table parameter, so it is specified in the function call as table = 'test'.

MySQL table

The DDL overrides the named collection setting for connection_pool_size.

MySQL database

MySQL Dictionary

Named collections for accessing PostgreSQL database

The description of parameters see postgresql. Additionally, there are aliases:
  • username for user
  • db for database.
The connection-pool settings of the PostgreSQL table engine (postgresql_connection_pool_size and the other postgresql_* settings) can also be stored in the collection or passed as key = value overrides. They apply to the PostgreSQL table engine, the postgresql table function, and the PostgreSQL database engine; an explicit SETTINGS clause on a table takes precedence over the values from the collection. Parameter addresses_expr is used in a collection instead of host:port. The parameter is optional, because there are other optional ones: host, hostname, port. The following pseudo code explains the priority:
Example of creation:
Example of configuration:

Example of using named collections with the postgresql function

Example of using named collections with database with engine PostgreSQL

PostgreSQL copies data from the named collection when the table is being created. A change in the collection does not affect the existing tables.

Example of using named collections with database with engine PostgreSQL

Example of using named collections with a dictionary with source POSTGRESQL

Named collections for accessing a remote ClickHouse database

The description of parameters see remote. Example of configuration:
secure is not needed for connection because of remoteSecure, but it can be used for dictionaries.

Example of using named collections with the remote/remoteSecure functions

Example of using named collections with a dictionary with source ClickHouse

Named collections for accessing Kafka

The description of parameters see Kafka.

DDL example

XML example

OAUTHBEARER/OIDC authentication

OAUTHBEARER options are extended librdkafka settings, so they must be nested under <kafka> inside each named collection. Top-level kafka_* keys configure the Kafka table engine. ClickHouse converts underscores in the nested XML element names to periods before passing them to librdkafka. The following example configures OAuth client credentials for an Azure Event Hubs namespace:
/etc/clickhouse-server/config.d/named_collections.xml
When ENGINE = Kafka(eventhub_one) uses a named collection, ClickHouse does not merge the global server <kafka> configuration. Create one collection per Event Hubs namespace when the broker address or OAuth scope differs, and include every required OIDC property in that collection. The from_env attributes in this example apply to XML-defined named collections and read their values from the ClickHouse server process environment. See substitution by environment variables for deployment and default-value details, and encrypting and hiding configuration to protect secrets in preprocessed configuration files.

Example of using named collections with a Kafka table

Both of the following examples use the same named collection my_kafka_cluster:

Named collections for backups

For the description of parameters see Backup and Restore.

DDL example

XML example

Named collections for accessing MongoDB Table and Dictionary

For the description of parameters see mongodb.

DDL example

XML example

MongoDB table

The DDL overrides the named collection setting for options.

MongoDB Dictionary

The dictionary uses my_collection, as specified in the named collection. To use another MongoDB collection, define a separate named collection with that value.
Last modified on October 2, 2026