---
title: "TO_BINARY"
description: "TO_BINARY SQL\u95A2\u6570\u306F\u3001\u5024\u3092BLOB\u306B\u5909\u63DB\u3057\u307E\u3059\u3002"
language: ja
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/ja/docs/invantive-universalsql/grammar/sql-functions/to-binary
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/to-binary
updated: 2026-12-04T14:36:00Z
license: https://documentation.invantive.eu/ja/
---

## 構文
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> TO_BINARY[TO_BINARY]:::quoted
    TO_BINARY --> End((END))
```

## 目的
`TO_BINARY` SQL関数は、値をBLOBに変換します。 テキストはUTF-8として解釈されます。

[[ASCII_TO_BLOB]]、[[UNICODE_TO_BLOB]]、[[HEX_TO_BLOB]]もあわせて参照してください。

パラメータ:
- 入力（`ANY`）：変換する値。

戻り値：入力をBLOBに変換した結果。

## 例
次の例では、テキスト `hi` をBLOBに変換し、base64表現を取得します：
```sql
select base64_encode(to_binary('hi'))

-------------------
aGk=
```
次の例では、テキスト `abc` をBLOBに変換し、バイト単位の長さを取得します：
```sql
select length(to_binary('abc'))

-------------------
3
```

