---
title: BINARY type
description: The BINARY type represents byte sequence values in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/data-types/binary-type
---

# `BINARY` type

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Represents byte sequence values.

## Syntax

```
BINARY
```

## Limits

The type supports byte sequences of any length greater or equal to 0.

## Literals

```
X { 'num [ ... ]' | "num [ ... ]" }
```

`num`: Any hexadecimal number from 0 to F.

The prefix `X` is case insensitive.

If the hexadecimal string literal has an odd length the parser prepends a 0.

## Examples

```sql
> SELECT X'1';
  [01]

> SELECT X'1ABF';
  [1A BF]

> SELECT X'';
  [ ]

> SELECT CAST('Spark' AS BINARY);
  [53 70 61 72 6B]
```

## Related

* [`STRING` type](https://docs.databricks.com/aws/en/sql/language-manual/data-types/string-type.md)
* [`cast` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/cast.md)
