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

> Documentation for the MsgPack format

# MsgPack

| Input | Output | Alias |
| - | - | - |
| ✔ | ✔ | |

<h2 id="description">
  Description
</h2>

ClickHouse supports reading and writing [MessagePack](https://msgpack.org/) data files.

<h2 id="data-types-matching">
  Data types matching
</h2>

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

<h2 id="example-usage">
  Example usage
</h2>

Writing to a file ".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;
```

<h2 id="format-settings">
  Format settings
</h2>

| Setting | Description | Default |
| - | - | - |
| [`input_format_msgpack_number_of_columns`](/reference/settings/formats/input-format#input_format_msgpack_number_of_columns) | the number of columns in inserted MsgPack data. Used for automatic schema inference from data. | `0` |
| [`output_format_msgpack_uuid_representation`](/reference/settings/formats/output-format#output_format_msgpack_uuid_representation) | the way how to output UUID in MsgPack format. | `EXT` |
