---
title: "TO_BINARY"
description: "La fonction SQL TO_BINARY convertit une valeur en BLOB."
language: fr
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/fr/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:35:55Z
license: https://documentation.invantive.eu/fr/
---

## Syntaxe
```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))
```

## Objet
La fonction SQL `TO_BINARY` convertit une valeur en BLOB. Le texte est interprété au format UTF-8.

Voir également [[ASCII_TO_BLOB]], [[UNICODE_TO_BLOB]] et [[HEX_TO_BLOB]].

Paramètres :
- Entrée (`ANY`) : valeur à convertir.

Renvoie : la valeur d'entrée convertie en BLOB.

## Exemples
L'exemple suivant convertit le texte `hi` en BLOB et récupère sa représentation en base64 :
```sql
select base64_encode(to_binary('hi'))

-------------------
aGk=
```
L'exemple suivant convertit le texte `abc` en BLOB et récupère sa longueur en octets :
```sql
select length(to_binary('abc'))

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

