> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-structure/sql-language-structure/binary-literals.md).

# Binary Literals

Binary literals can be written in one of the following formats: `b'value'`, `B'value'` or `0bvalue`, where `value` is a string composed by `0` and `1` digits.

Binary literals are interpreted as binary strings, and are convenient to represent [VARBINARY](/docs/server/reference/data-types/string-data-types/varbinary.md), [BINARY](/docs/server/reference/data-types/string-data-types/binary.md) or [BIT](/docs/server/reference/data-types/numeric-data-types/bit.md) values.

To convert a binary literal into an integer, just add `0`.

## Examples

Printing the value as a binary string:

```sql
SELECT 0b1000001;
+-----------+
| 0b1000001 |
+-----------+
| A         |
+-----------+
```

Converting the same value into a number:

```sql
SELECT 0b1000001+0;
+-------------+
| 0b1000001+0 |
+-------------+
|          65 |
+-------------+
```

## See Also

* [BIN()](/docs/server/reference/sql-functions/string-functions/bin.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
