> ## 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.

> StripeLog テーブルエンジンのドキュメント

# StripeLog テーブルエンジン

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 />

このエンジンは、ログエンジンファミリーに属します。ログエンジンの共通の特性と違いについては、[Log Engine Family](/docs/ja/reference/engines/table-engines/log-family/index) の記事を参照してください。

このエンジンは、少量のデータ (100万行未満) を含む多数のテーブルに書き込む必要がある場合に使用します。たとえば、アトミックな処理が必要な、変換用の受信データバッチを保存するテーブルとして使用できます。ClickHouse server では、この種類のテーブルを 10 万個程度まで実用的に運用できます。多数のテーブルが必要な場合は、[Log](/docs/ja/reference/engines/table-engines/log-family/log) よりこのテーブルエンジンを優先して使用してください。ただし、そのぶん読み取り効率は低下します。

<div id="table_engines-stripelog-creating-a-table">
  ## テーブルの作成
</div>

```sql theme={null}
CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
(
    column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
    column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
    ...
) ENGINE = StripeLog
```

[CREATE TABLE](/docs/ja/reference/statements/create/table)クエリの詳しい説明については、こちらを参照してください。

<div id="table_engines-stripelog-writing-the-data">
  ## データの書き込み
</div>

`StripeLog` エンジンは、すべてのカラムを1つのファイルに格納します。`INSERT` クエリごとに、ClickHouse はテーブルファイルの末尾にデータブロックを追記し、カラムを1つずつ書き込みます。

各テーブルに対して、ClickHouse は次のファイルを書き込みます。

* `data.bin` — データファイル。
* `index.mrk` — マークを格納するファイル。マークには、挿入された各データブロック内の各カラムのオフセットが含まれます。

`StripeLog` エンジンは、`ALTER UPDATE` および `ALTER DELETE` 操作をサポートしていません。

<div id="table_engines-stripelog-reading-the-data">
  ## データの読み取り
</div>

マークファイルにより、ClickHouse はデータの読み取りを並列化できます。そのため、`SELECT` クエリが返す行の順序は一定ではありません。行をソートするには、`ORDER BY` 句を使用します。

<div id="table_engines-stripelog-example-of-use">
  ## 使用例
</div>

テーブルの作成:

```sql theme={null}
CREATE TABLE stripe_log_table
(
    timestamp DateTime,
    message_type String,
    message String
)
ENGINE = StripeLog
```

データの挿入:

```sql theme={null}
INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message')
INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message')
```

2つの`INSERT`クエリを使用して、`data.bin`ファイル内に2つのデータブロックを作成しました。

ClickHouseは、データを選択するときに複数のスレッドを使用します。各スレッドは別々のデータブロックを読み取り、処理が完了した時点で結果の行を個別に返します。そのため、ほとんどの場合、出力内の行ブロックの順序は、入力内の同じブロックの順序と一致しません。たとえば、次のようになります。

```sql theme={null}
SELECT * FROM stripe_log_table
```

```text theme={null}
┌───────────timestamp─┬─message_type─┬─message────────────────────┐
│ 2019-01-18 14:27:32 │ REGULAR      │ The second regular message │
│ 2019-01-18 14:34:53 │ WARNING      │ The first warning message  │
└─────────────────────┴──────────────┴────────────────────────────┘
┌───────────timestamp─┬─message_type─┬─message───────────────────┐
│ 2019-01-18 14:23:43 │ REGULAR      │ The first regular message │
└─────────────────────┴──────────────┴───────────────────────────┘
```

結果をソートする (デフォルトでは昇順) ：

```sql theme={null}
SELECT * FROM stripe_log_table ORDER BY timestamp
```

```text theme={null}
┌───────────timestamp─┬─message_type─┬─message────────────────────┐
│ 2019-01-18 14:23:43 │ REGULAR      │ The first regular message  │
│ 2019-01-18 14:27:32 │ REGULAR      │ The second regular message │
│ 2019-01-18 14:34:53 │ WARNING      │ The first warning message  │
└─────────────────────┴──────────────┴────────────────────────────┘
```
