> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ClickHouse에서 JDBC를 통해 외부 데이터베이스에 연결할 수 있습니다.

# JDBC 테이블 엔진

export const CloudNotSupportedBadge = () => {
  return <div className="cloudNotSupportedBadge">
            <div className="cloudNotSupportedIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.5" d="M6.33366 12.6666L12.3739 12.6667C13.6593 12.6667 14.7073 11.6187 14.7073 10.3334C14.7073 9.04804 13.6593 8.00003 12.3739 8.00003C12.3739 8.00003 12.3337 7.66659 12.0003 7.33325M10.667 5.33322C8.00033 2.33325 4.45395 4.78537 4.14195 6.68203C2.55728 6.7627 1.29395 8.06203 1.29395 9.6667C1.29395 11.3234 2.66699 12.6666 4.00033 12.6666" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.5" d="M2.66699 14L12.0003 4.66663" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>

        </div>
            Not supported in ClickHouse Cloud
        </div>;
};

<Note>
  clickhouse-jdbc-bridge에는 Experimental 코드가 포함되어 있으며 더 이상 지원되지 않습니다. 안정성 문제와 보안 취약점이 있을 수 있습니다. 사용에 따른 위험은 사용자 책임입니다.
  ClickHouse는 ClickHouse에 내장된 테이블 함수를 사용할 것을 권장합니다. 이 방식은 임시 쿼리 시나리오(Postgres, MySQL, MongoDB 등)에서 더 나은 대안이 됩니다.
</Note>

ClickHouse가 [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity)를 통해 외부 데이터베이스에 연결할 수 있게 합니다.

JDBC 연결을 구현하기 위해 ClickHouse는 데몬으로 실행되어야 하는 별도의 프로그램인 [clickhouse-jdbc-bridge](https://github.com/ClickHouse/clickhouse-jdbc-bridge)를 사용합니다.

이 엔진은 [널 허용](/ko/reference/data-types/nullable) 데이터 타입을 지원합니다.

<div id="creating-a-table">
  ## 테이블 만들기
</div>

```sql theme={null}
CREATE TABLE [IF NOT EXISTS] [db.]table_name
(
    columns list...
)
ENGINE = JDBC(datasource, external_database, external_table)
```

**엔진 매개변수**

* `datasource` — 외부 DBMS의 URI 또는 이름입니다.

  URI 형식: `jdbc:<driver_name>://<host_name>:<port>/?user=<username>&password=<password>`.
  MySQL 예시: `jdbc:mysql://localhost:3306/?user=root&password=root`.

* `external_database` — 외부 DBMS에 있는 데이터베이스 이름 또는 명시적으로 정의한 테이블 스키마입니다(예시 참조).

* `external_table` — 외부 데이터베이스에 있는 테이블 이름 또는 `select * from table1 where column1=1`과 같은 select 쿼리입니다.

* 이러한 매개변수는 [이름이 지정된 컬렉션](/ko/concepts/features/configuration/server-config/named-collections)을 사용해 전달할 수도 있습니다.

<div id="usage-example">
  ## 사용 예시
</div>

MySQL 서버의 콘솔 클라이언트에 직접 연결하여 테이블(table)을 생성하는 방법:

```text theme={null}
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 서버에서 테이블을 생성하고 해당 테이블의 데이터를 조회합니다:

```sql theme={null}
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 theme={null}
SELECT *
FROM jdbc_table
```

```text theme={null}
┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐
│      1 │         ᴺᵁᴸᴸ │     2 │           ᴺᵁᴸᴸ │
└────────┴──────────────┴───────┴────────────────┘
```

```sql theme={null}
INSERT INTO jdbc_table(`int_id`, `float`)
SELECT toInt32(number), toFloat32(number * 1.0)
FROM system.numbers
```

<div id="see-also">
  ## 관련 항목
</div>

* [JDBC 테이블 함수](/ko/reference/functions/table-functions/jdbc).
