> ## 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의 SQL 시작 스크립트를 구성하고 사용하는 방법을 안내합니다

# 시작 스크립트

ClickHouse는 시작 시 서버 구성에서 임의의 SQL 쿼리를 실행할 수 있습니다. 이는 마이그레이션이나 자동 스키마 생성에 유용합니다.

```xml theme={null}
<clickhouse>
    <startup_scripts>
        <throw_on_error>false</throw_on_error>
        <scripts>
            <query>CREATE ROLE OR REPLACE test_role</query>
        </scripts>
        <scripts>
            <query>CREATE TABLE TestTable (id UInt64) ENGINE=TinyLog</query>
            <condition>SELECT 1;</condition>
        </scripts>
        <scripts>
            <query>CREATE DICTIONARY test_dict (...) SOURCE(CLICKHOUSE(...))</query>
            <user>default</user>
        </scripts>
    </startup_scripts>
</clickhouse>
```

ClickHouse는 지정된 순서대로 `startup_scripts`의 모든 쿼리를 순차적으로 실행합니다. 쿼리 중 하나가 실패하더라도 이후 쿼리의 실행은 중단되지 않습니다. 그러나 `throw_on_error`가 true로 설정된 경우,
스크립트 실행 중 오류가 발생하면 서버가 시작되지 않습니다.

config에서 조건부 쿼리를 지정할 수 있습니다. 이 경우 해당 쿼리는 조건 쿼리가 값 `1` 또는 `true`를 반환할 때만 실행됩니다.

<Note>
  조건 쿼리가 `1` 또는 `true` 이외의 값을 반환하면 결과는 `false`로 해석되며, 해당 쿼리는 실행되지 않습니다.
</Note>
