ClickHouse/docs/ja/sql-reference/table-functions/jdbc.md

41 lines
1.3 KiB
Markdown
Raw Normal View History

2020-04-04 09:15:31 +00:00
---
machine_translated: true
machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd
2020-04-04 09:15:31 +00:00
toc_priority: 43
toc_title: jdbc
---
# jdbc {#table-function-jdbc}
2021-06-11 09:37:38 +00:00
`jdbc(datasource, schema, table)` -JDBCドライバ経由で接続されたテーブルを返します。
2020-04-04 09:15:31 +00:00
2021-06-11 09:37:38 +00:00
このテーブル関数には、別々の [clickhouse-jdbc-bridge](https://github.com/ClickHouse/clickhouse-jdbc-bridge) 実行するプログラム。
Null許容型をサポートします(照会されるリモートテーブルのDDLに基づきます)。
2020-04-04 09:15:31 +00:00
**例**
``` sql
SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table')
```
``` sql
2021-06-11 09:37:38 +00:00
SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'select * from schema.table')
2020-04-04 09:15:31 +00:00
```
``` sql
2021-06-11 09:37:38 +00:00
SELECT * FROM jdbc('mysql-dev?p1=233', 'num Int32', 'select toInt32OrZero(''{{p1}}'') as num')
```
``` sql
SELECT *
FROM jdbc('mysql-dev?p1=233', 'num Int32', 'select toInt32OrZero(''{{p1}}'') as num')
```
``` sql
SELECT a.datasource AS server1, b.datasource AS server2, b.name AS db
FROM jdbc('mysql-dev?datasource_column', 'show databases') a
INNER JOIN jdbc('self?datasource_column', 'show databases') b ON a.Database = b.name
2020-04-04 09:15:31 +00:00
```
[元の記事](https://clickhouse.tech/docs/en/query_language/table_functions/jdbc/) <!--hide-->