= Named collections in Clickhouse =

Named collections are useful for functions that require credentials, for example:

create named collection remote_clickhouse as
host='xxx',
user='xxx',
password='xxx';

Then, use the credentials in the remote() function like so (the first parameter):

INSERT INTO local_db.local_table SELECT *
FROM remote(remote_clickhouse, database = 'remote_db', table = 'remote_table')
WHERE toDate(ts) = today()

as per usual, everything in clickhouse is a table, so to review your collections, run:

SELECT *
FROM system.named_collections

Query id: 4f6baebb-711e-4c90-8d89-297e2b4eee47

┌─name──────────────┬─collection──────────────────────────────────────────────────┐
│ remote_clickhouse │ {'host':'[HIDDEN]','password':'[HIDDEN]','user':'[HIDDEN]'} │
└───────────────────┴─────────────────────────────────────────────────────────────┘

1 row in set. Elapsed: 0.001 sec.

= References =