> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> 이 엔진은 SQLite로 데이터를 가져오고 내보낼 수 있으며, ClickHouse에서 SQLite 테이블에 직접 쿼리하는 기능도 지원합니다.

# SQLite 테이블 엔진

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>
            ClickHouse Cloud에서 지원되지 않음
        </div>;
};

<CloudNotSupportedBadge />

이 엔진은 SQLite로 데이터를 가져오고 내보낼 수 있으며, ClickHouse에서 SQLite 테이블에 직접 쿼리할 수도 있습니다.

<div id="creating-a-table">
  ## 테이블 생성
</div>

```sql theme={null}
    CREATE TABLE [IF NOT EXISTS] [db.]table_name
    (
        name1 [type1],
        name2 [type2], ...
    ) ENGINE = SQLite('db_path', 'table')
```

**엔진 매개변수**

* `db_path` — 데이터베이스가 저장된 SQLite 파일의 경로입니다.
* `table` — SQLite 데이터베이스 내 테이블 이름이거나, SQLite에 그대로 전달되는 쿼리입니다([테이블 이름 대신 쿌리 전달](#passing-a-query) 참조).

<div id="passing-a-query">
  ## 테이블 이름 대신 쿼리 전달하기
</div>

테이블 이름 대신 `table` 인수에 SQLite로 그대로 전달되는 `SELECT` 쿼리를 지정할 수 있습니다. 테이블의 구조는 쿌리 결과를 바탕으로 자동 추론됩니다. 쿼리는 하위 쿼리로 작성하거나 `query` 함수로 감쌀 수 있습니다.

```sql theme={null}
CREATE TABLE sqlite_table ENGINE = SQLite('sqlite.db', (SELECT col1, col2 FROM table1 WHERE col2 > 1));
CREATE TABLE sqlite_table ENGINE = SQLite('sqlite.db', query('SELECT col1, col2 FROM table1 WHERE col2 > 1'));
```

이러한 테이블은 읽기 전용이므로 `INSERT`로 데이터를 삽입할 수 없습니다. 동일한 구문은 [`sqlite`](/docs/ko/reference/functions/table-functions/sqlite) 테이블 함수에서도 지원됩니다.

<Note>
  하위 쿼리 형식인 `(SELECT ...)`는 ClickHouse에서 파싱된 뒤 다시 직렬화되어 SQLite로 전송됩니다. 따라서 유효한 ClickHouse SQL이어야 합니다. ClickHouse가 파싱하지 못하는 SQLite 전용 구문을 전달하려면 `query('...')` 형식을 사용하십시오. 이 형식의 텍스트는 그대로 SQLite로 전송됩니다.

  상위 ClickHouse 쿼리의 `WHERE`, `LIMIT`, 집계 등은 전달된 쿼리로 **푸시다운되지** 않으며, 전체 쿼리 결과를 가져온 후 ClickHouse에서 적용됩니다. SQLite에서 읽을 데이터를 제한하려면 전달된 쿼리 안에 filter를 넣으십시오. [`external_table_strict_query = 1`](/docs/ko/reference/settings/session-settings#external_table_strict_query)을 사용하면 푸시다운할 수 없는 상위 filter는 로컬에서 적용되는 대신 예외와 함께 거부됩니다.
</Note>

<div id="data-types-support">
  ## 데이터 타입 지원
</div>

테이블 정의에서 ClickHouse 컬럼 타입을 명시적으로 지정하면, SQLite TEXT 컬럼에서 다음 ClickHouse 타입으로 파싱할 수 있습니다:

* [Date](/docs/ko/reference/data-types/date), [Date32](/docs/ko/reference/data-types/date32)
* [DateTime](/docs/ko/reference/data-types/datetime), [DateTime64](/docs/ko/reference/data-types/datetime64)
* [UUID](/docs/ko/reference/data-types/uuid)
* [Enum8, Enum16](/docs/ko/reference/data-types/enum)
* [Decimal32, Decimal64, Decimal128, Decimal256](/docs/ko/reference/data-types/decimal)
* [FixedString](/docs/ko/reference/data-types/fixedstring)
* 모든 정수 타입([UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64](/docs/ko/reference/data-types/int-uint))
* [Float32, Float64](/docs/ko/reference/data-types/float)

기본 타입 매핑은 [SQLite 데이터베이스 엔진](/docs/ko/reference/engines/database-engines/sqlite#data_types-support) 문서를 참조하십시오.

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

다음은 SQLite 테이블을 생성하는 쿼리입니다:

```sql theme={null}
SHOW CREATE TABLE sqlite_db.table2;
```

```text theme={null}
CREATE TABLE SQLite.table2
(
    `col1` Nullable(Int32),
    `col2` Nullable(String)
)
ENGINE = SQLite('sqlite.db','table2');
```

테이블에서 데이터를 반환합니다:

```sql theme={null}
SELECT * FROM sqlite_db.table2 ORDER BY col1;
```

```text theme={null}
┌─col1─┬─col2──┐
│    1 │ text1 │
│    2 │ text2 │
│    3 │ text3 │
└──────┴───────┘
```

**관련 항목**

* [SQLite](/docs/ko/reference/engines/database-engines/sqlite) 엔진
* [sqlite](/docs/ko/reference/functions/table-functions/sqlite) 테이블 함수
