mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
1.2 KiB
1.2 KiB
toc_priority | toc_title |
---|---|
5 | MongoDB |
MongoDB
MongoDB engine is read-only table engine which allows to read data (SELECT
queries) from remote MongoDB collection. Engine supports only non-nested data types. INSERT
queries are not supported.
Creating a Table
CREATE TABLE [IF NOT EXISTS] [db.]table_name
(
name1 [type1],
name2 [type2],
...
) ENGINE = MongoDB(host:port, database, collection, user, password);
Engine Parameters
-
host:port
— MongoDB server address. -
database
— Remote database name. -
collection
— Remote collection name. -
user
— MongoDB user. -
password
— User password.
Usage Example
Table in ClickHouse which allows to read data from MongoDB collection:
CREATE TABLE mongo_table
(
key UInt64,
data String
) ENGINE = MongoDB('mongo1:27017', 'test', 'simple_table', 'testuser', 'clickhouse');
Query:
SELECT COUNT() FROM mongo_table;
┌─count()─┐
│ 4 │
└─────────┘