Merge pull request #35277 from den-crane/Docs/named-collections

Doc. named connections. Сontinuation.
This commit is contained in:
Kseniia Sumarokova 2022-03-14 19:48:12 +01:00 committed by GitHub
commit 8c3caf3805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 203 additions and 10 deletions

View File

@ -41,7 +41,7 @@ Example of configuration:
</clickhouse>
```
### An example of using named connections with the s3 function
### Example of using named connections with the s3 function
```sql
INSERT INTO FUNCTION s3(s3_mydata, url = 'https://s3.us-east-1.amazonaws.com/yourbucket/mydata/test_file.tsv.gz',
@ -57,7 +57,7 @@ FROM s3(s3_mydata, url = 'https://s3.us-east-1.amazonaws.com/yourbucket/mydata/t
1 rows in set. Elapsed: 0.279 sec. Processed 10.00 thousand rows, 90.00 KB (35.78 thousand rows/s., 322.02 KB/s.)
```
### An example of using named connections with an S3 table
### Example of using named connections with an S3 table
```sql
CREATE TABLE s3_engine_table (number Int64)
@ -72,7 +72,7 @@ SELECT * FROM s3_engine_table LIMIT 3;
└────────┘
```
## Named connections for accessing MySQL database.
## Named connections for accessing MySQL database
The description of parameters see [mysql](../sql-reference/table-functions/mysql.md).
@ -94,7 +94,7 @@ Example of configuration:
</clickhouse>
```
### An example of using named connections with the mysql function
### Example of using named connections with the mysql function
```sql
SELECT count() FROM mysql(mymysql, table = 'test');
@ -104,7 +104,7 @@ SELECT count() FROM mysql(mymysql, table = 'test');
└─────────┘
```
### An example of using named connections with an MySQL table
### Example of using named connections with an MySQL table
```sql
CREATE TABLE mytable(A Int64) ENGINE = MySQL(mymysql, table = 'test', connection_pool_size=3, replace_query=0);
@ -115,7 +115,20 @@ SELECT count() FROM mytable;
└─────────┘
```
### An example of using named with an external dictionary with source MySQL
### Example of using named connections with database with engine MySQL
```sql
CREATE DATABASE mydatabase ENGINE = MySQL(mymysql);
SHOW TABLES FROM mydatabase;
┌─name───┐
│ source │
│ test │
└────────┘
```
### Example of using named connections with an external dictionary with source MySQL
```sql
CREATE DICTIONARY dict (A Int64, B String)
@ -130,3 +143,87 @@ SELECT dictGet('dict', 'B', 2);
│ two │
└─────────────────────────┘
```
## Named connections for accessing PostgreSQL database
The description of parameters see [postgresql](../sql-reference/table-functions/postgresql.md).
Example of configuration:
```xml
<clickhouse>
<named_collections>
<mypg>
<user>pguser</user>
<password>jw8s0F4</password>
<host>127.0.0.1</host>
<port>5432</port>
<database>test</database>
<schema>test_schema</schema>
<connection_pool_size>8</connection_pool_size>
</mypg>
</named_collections>
</clickhouse>
```
### Example of using named connections with the postgresql function
```sql
SELECT * FROM postgresql(mypg, table = 'test');
┌─a─┬─b───┐
│ 2 │ two │
│ 1 │ one │
└───┴─────┘
SELECT * FROM postgresql(mypg, table = 'test', schema = 'public');
┌─a─┐
│ 1 │
│ 2 │
│ 3 │
└───┘
```
### Example of using named connections with database with engine PostgreSQL
```sql
CREATE TABLE mypgtable (a Int64) ENGINE = PostgreSQL(mypg, table = 'test', schema = 'public');
SELECT * FROM mypgtable;
┌─a─┐
│ 1 │
│ 2 │
│ 3 │
└───┘
```
### Example of using named connections with database with engine PostgreSQL
```sql
CREATE DATABASE mydatabase ENGINE = PostgreSQL(mypg);
SHOW TABLES FROM mydatabase
┌─name─┐
│ test │
└──────┘
```
### Example of using named connections with an external dictionary with source POSTGRESQL
```sql
CREATE DICTIONARY dict (a Int64, b String)
PRIMARY KEY a
SOURCE(POSTGRESQL(NAME mypg TABLE test))
LIFETIME(MIN 1 MAX 2)
LAYOUT(HASHED());
SELECT dictGet('dict', 'b', 2);
┌─dictGet('dict', 'b', 2)─┐
│ two │
└─────────────────────────┘
```

View File

@ -24,7 +24,7 @@ $ cat /etc/clickhouse-server/config.d/named_collections.xml
</clickhouse>
```
## Именованные соединения для доступа к S3.
## Именованные соединения для доступа к S3
Описание параметров смотри [Табличная Функция S3](../sql-reference/table-functions/s3.md).
@ -72,7 +72,7 @@ SELECT * FROM s3_engine_table LIMIT 3;
└────────┘
```
## Пример использования именованных соединений с базой данных MySQL.
## Пример использования именованных соединений с базой данных MySQL
Описание параметров смотри [mysql](../sql-reference/table-functions/mysql.md).
@ -104,7 +104,7 @@ SELECT count() FROM mysql(mymysql, table = 'test');
└─────────┘
```
### Пример использования именованных таблицей с движком mysql
### Пример использования именованных соединений таблицей с движком mysql
```sql
CREATE TABLE mytable(A Int64) ENGINE = MySQL(mymysql, table = 'test', connection_pool_size=3, replace_query=0);
@ -115,7 +115,20 @@ SELECT count() FROM mytable;
└─────────┘
```
### Пример использования именованных с внешним словарем с источником mysql
### Пример использования именованных соединений базой данных с движком MySQL
```sql
CREATE DATABASE mydatabase ENGINE = MySQL(mymysql);
SHOW TABLES FROM mydatabase;
┌─name───┐
│ source │
│ test │
└────────┘
```
### Пример использования именованных соединений с внешним словарем с источником mysql
```sql
CREATE DICTIONARY dict (A Int64, B String)
@ -130,3 +143,86 @@ SELECT dictGet('dict', 'B', 2);
│ two │
└─────────────────────────┘
```
## Пример использования именованных соединений с базой данных PostgreSQL
Описание параметров смотри [postgresql](../sql-reference/table-functions/postgresql.md).
Пример конфигурации:
```xml
<clickhouse>
<named_collections>
<mypg>
<user>pguser</user>
<password>jw8s0F4</password>
<host>127.0.0.1</host>
<port>5432</port>
<database>test</database>
<schema>test_schema</schema>
<connection_pool_size>8</connection_pool_size>
</mypg>
</named_collections>
</clickhouse>
```
### Пример использования именованных соединений с табличной функцией postgresql
```sql
SELECT * FROM postgresql(mypg, table = 'test');
┌─a─┬─b───┐
│ 2 │ two │
│ 1 │ one │
└───┴─────┘
SELECT * FROM postgresql(mypg, table = 'test', schema = 'public');
┌─a─┐
│ 1 │
│ 2 │
│ 3 │
└───┘
```
### Пример использования именованных соединений таблицей с движком PostgreSQL
```sql
CREATE TABLE mypgtable (a Int64) ENGINE = PostgreSQL(mypg, table = 'test', schema = 'public');
SELECT * FROM mypgtable;
┌─a─┐
│ 1 │
│ 2 │
│ 3 │
└───┘
```
### Пример использования именованных соединений базой данных с движком PostgreSQL
```sql
CREATE DATABASE mydatabase ENGINE = PostgreSQL(mypg);
SHOW TABLES FROM mydatabase
┌─name─┐
│ test │
└──────┘
```
### Пример использования именованных соединений с внешним словарем с источником POSTGRESQL
```sql
CREATE DICTIONARY dict (a Int64, b String)
PRIMARY KEY a
SOURCE(POSTGRESQL(NAME mypg TABLE test))
LIFETIME(MIN 1 MAX 2)
LAYOUT(HASHED());
SELECT dictGet('dict', 'b', 2);
┌─dictGet('dict', 'b', 2)─┐
│ two │
└─────────────────────────┘
```