mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 12:22:12 +00:00
39 lines
1.1 KiB
Markdown
39 lines
1.1 KiB
Markdown
---
|
||
toc_priority: 43
|
||
toc_title: jdbc
|
||
---
|
||
|
||
# jdbc {#table-function-jdbc}
|
||
|
||
`jdbc(datasource, schema, table)` -返回通过JDBC驱动程序连接的表。
|
||
|
||
此表函数需要单独的 [clickhouse-jdbc-bridge](https://github.com/ClickHouse/clickhouse-jdbc-bridge) 程序才能运行。
|
||
它支持可空类型(基于查询的远程表的DDL)。
|
||
|
||
**示例**
|
||
|
||
``` sql
|
||
SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table')
|
||
```
|
||
|
||
``` sql
|
||
SELECT * FROM jdbc('mysql://localhost:3306/?user=root&password=root', 'select * from schema.table')
|
||
```
|
||
|
||
``` sql
|
||
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
|
||
```
|
||
|
||
[原始文章](https://clickhouse.com/docs/en/query_language/table_functions/jdbc/) <!--hide-->
|