mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 05:03:20 +00:00
cd14f9ebcb
* split up select.md * array-join.md basic refactoring * distinct.md basic refactoring * format.md basic refactoring * from.md basic refactoring * group-by.md basic refactoring * having.md basic refactoring * additional index.md refactoring * into-outfile.md basic refactoring * join.md basic refactoring * limit.md basic refactoring * limit-by.md basic refactoring * order-by.md basic refactoring * prewhere.md basic refactoring * adjust operators/index.md links * adjust sample.md links * adjust more links * adjust operatots links * fix some links * adjust aggregate function article titles * basic refactor of remaining select clauses * absolute paths in make_links.sh * run make_links.sh * remove old select.md locations * translate docs/es * translate docs/fr * translate docs/fa * remove old operators.md location * change operators.md links * adjust links in docs/es * adjust links in docs/es * minor texts adjustments * wip * update machine translations to use new links * fix changelog * es build fixes * get rid of some select.md links * temporary adjust ru links * temporary adjust more ru links * improve curly brace handling * adjust ru as well * fa build fix * ru link fixes * zh link fixes * temporary disable part of anchor checks
91 lines
2.7 KiB
Markdown
91 lines
2.7 KiB
Markdown
---
|
||
machine_translated: true
|
||
machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd
|
||
toc_priority: 34
|
||
toc_title: JDBC
|
||
---
|
||
|
||
# JDBC {#table-engine-jdbc}
|
||
|
||
ClickHouse üzerinden harici veritabanlarına bağlanmak için izin verir [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity).
|
||
|
||
JDBC bağlantısını uygulamak için ClickHouse ayrı programı kullanır [clickhouse-JDBC-köprü](https://github.com/alex-krash/clickhouse-jdbc-bridge) bu bir daemon olarak çalışmalıdır.
|
||
|
||
Bu motor destekler [Nullable](../../../sql-reference/data-types/nullable.md) veri türü.
|
||
|
||
## Tablo oluşturma {#creating-a-table}
|
||
|
||
``` sql
|
||
CREATE TABLE [IF NOT EXISTS] [db.]table_name
|
||
(
|
||
columns list...
|
||
)
|
||
ENGINE = JDBC(dbms_uri, external_database, external_table)
|
||
```
|
||
|
||
**Motor Parametreleri**
|
||
|
||
- `dbms_uri` — URI of an external DBMS.
|
||
|
||
Biçimli: `jdbc:<driver_name>://<host_name>:<port>/?user=<username>&password=<password>`.
|
||
MySQL örneği: `jdbc:mysql://localhost:3306/?user=root&password=root`.
|
||
|
||
- `external_database` — Database in an external DBMS.
|
||
|
||
- `external_table` — Name of the table in `external_database`.
|
||
|
||
## Kullanım Örneği {#usage-example}
|
||
|
||
Doğrudan konsol istemcisine bağlanarak MySQL sunucusunda bir tablo oluşturma:
|
||
|
||
``` text
|
||
mysql> CREATE TABLE `test`.`test` (
|
||
-> `int_id` INT NOT NULL AUTO_INCREMENT,
|
||
-> `int_nullable` INT NULL DEFAULT NULL,
|
||
-> `float` FLOAT NOT NULL,
|
||
-> `float_nullable` FLOAT NULL DEFAULT NULL,
|
||
-> PRIMARY KEY (`int_id`));
|
||
Query OK, 0 rows affected (0,09 sec)
|
||
|
||
mysql> insert into test (`int_id`, `float`) VALUES (1,2);
|
||
Query OK, 1 row affected (0,00 sec)
|
||
|
||
mysql> select * from test;
|
||
+------+----------+-----+----------+
|
||
| int_id | int_nullable | float | float_nullable |
|
||
+------+----------+-----+----------+
|
||
| 1 | NULL | 2 | NULL |
|
||
+------+----------+-----+----------+
|
||
1 row in set (0,00 sec)
|
||
```
|
||
|
||
ClickHouse Server'da bir tablo oluşturma ve ondan veri seçme:
|
||
|
||
``` sql
|
||
CREATE TABLE jdbc_table
|
||
(
|
||
`int_id` Int32,
|
||
`int_nullable` Nullable(Int32),
|
||
`float` Float32,
|
||
`float_nullable` Nullable(Float32)
|
||
)
|
||
ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root&password=root', 'test', 'test')
|
||
```
|
||
|
||
``` sql
|
||
SELECT *
|
||
FROM jdbc_table
|
||
```
|
||
|
||
``` text
|
||
┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐
|
||
│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │
|
||
└────────┴──────────────┴───────┴────────────────┘
|
||
```
|
||
|
||
## Ayrıca Bakınız {#see-also}
|
||
|
||
- [JDBC tablo işlevi](../../../sql-reference/table-functions/jdbc.md).
|
||
|
||
[Orijinal makale](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/) <!--hide-->
|