---
title: octet_length function
description: Learn the syntax of the octet\_length function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/octet_length
---

# `octet_length` function

**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

Returns the byte length of string data or number of bytes of binary data.

## Syntax

```
octet_length(expr)
```

## Arguments

* `expr`: A STRING or BINARY expression.

## Returns

An INTEGER.

## Examples

```sql
> SELECT octet_length('Spark SQL');
 9
> SELECT octet_length('서울시');
 9
```

## Related functions

* [`bit_length` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_length.md)
* [`length` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/length.md)
* [`char_length` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/char_length.md)
* [`character_length` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/character_length.md)
