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

> MsgPack フォーマットのドキュメント

# MsgPack

| 入力 | 出力 | エイリアス |
| -- | -- | ----- |
| ✔  | ✔  |       |

<div id="description">
  ## 説明
</div>

ClickHouse は、[MessagePack](https://msgpack.org/) のデータファイルの読み書きをサポートしています。

<div id="data-types-matching">
  ## データ型の対応
</div>

| MessagePack データ型 (`INSERT`)                                        | ClickHouse データ型                                                                     | MessagePack データ型 (`SELECT`)        |
| ------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | ---------------------------------- |
| `uint N`, `positive fixint`                                        | [`UIntN`](/ja/reference/data-types/int-uint)                                        | `uint N`                           |
| `int N`, `negative fixint`                                         | [`IntN`](/ja/reference/data-types/int-uint)                                         | `int N`                            |
| `bool`                                                             | [`UInt8`](/ja/reference/data-types/int-uint)                                        | `uint 8`                           |
| `fixstr`, `str 8`, `str 16`, `str 32`, `bin 8`, `bin 16`, `bin 32` | [`String`](/ja/reference/data-types/string)                                         | `bin 8`, `bin 16`, `bin 32`        |
| `fixstr`, `str 8`, `str 16`, `str 32`, `bin 8`, `bin 16`, `bin 32` | [`FixedString`](/ja/reference/data-types/fixedstring)                               | `bin 8`, `bin 16`, `bin 32`        |
| `float 32`                                                         | [`Float32`](/ja/reference/data-types/float)                                         | `float 32`                         |
| `float 64`                                                         | [`Float64`](/ja/reference/data-types/float)                                         | `float 64`                         |
| `uint 16`                                                          | [`Date`](/ja/reference/data-types/date)                                             | `uint 16`                          |
| `int 32`                                                           | [`Date32`](/ja/reference/data-types/date32)                                         | `int 32`                           |
| `uint 32`                                                          | [`DateTime`](/ja/reference/data-types/datetime)                                     | `uint 32`                          |
| `uint 64`                                                          | [`DateTime64`](/ja/reference/data-types/datetime)                                   | `uint 64`                          |
| `fixarray`, `array 16`, `array 32`                                 | [`Array`](/ja/reference/data-types/array)/[`Tuple`](/ja/reference/data-types/tuple) | `fixarray`, `array 16`, `array 32` |
| `fixmap`, `map 16`, `map 32`                                       | [`Map`](/ja/reference/data-types/map)                                               | `fixmap`, `map 16`, `map 32`       |
| `uint 32`                                                          | [`IPv4`](/ja/reference/data-types/ipv4)                                             | `uint 32`                          |
| `bin 8`                                                            | [`String`](/ja/reference/data-types/string)                                         | `bin 8`                            |
| `int 8`                                                            | [`Enum8`](/ja/reference/data-types/enum)                                            | `int 8`                            |
| `bin 8`                                                            | [`(U)Int128`/`(U)Int256`](/ja/reference/data-types/int-uint)                        | `bin 8`                            |
| `int 32`                                                           | [`Decimal32`](/ja/reference/data-types/decimal)                                     | `int 32`                           |
| `int 64`                                                           | [`Decimal64`](/ja/reference/data-types/decimal)                                     | `int 64`                           |
| `bin 8`                                                            | [`Decimal128`/`Decimal256`](/ja/reference/data-types/decimal)                       | `bin 8 `                           |

<div id="example-usage">
  ## 使用例
</div>

".msgpk" ファイルへの書き込み:

```sql theme={null}
$ clickhouse-client --query="CREATE TABLE msgpack (array Array(UInt8)) ENGINE = Memory;"
$ clickhouse-client --query="INSERT INTO msgpack VALUES ([0, 1, 2, 3, 42, 253, 254, 255]), ([255, 254, 253, 42, 3, 2, 1, 0])";
$ clickhouse-client --query="SELECT * FROM msgpack FORMAT MsgPack" > tmp_msgpack.msgpk;
```

<div id="format-settings">
  ## フォーマット設定
</div>

| 設定                                                                                                                      | 説明                                              | デフォルト |
| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | ----- |
| [`input_format_msgpack_number_of_columns`](/ja/reference/settings/formats#input_format_msgpack_number_of_columns)       | 挿入する MsgPack データのカラム数。データからスキーマを自動推論する際に使用されます。 | `0`   |
| [`output_format_msgpack_uuid_representation`](/ja/reference/settings/formats#output_format_msgpack_uuid_representation) | MsgPack フォーマットで UUID を出力する際の形式。                 | `EXT` |
