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

# `len` function

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

Returns the character length of string data or number of bytes of binary data. This function is a synonym for [`character_length` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/character_length.md) and [`char_length` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/char_length.md).

## Syntax

```
len(expr)
```

## Arguments

* `expr`: A STRING or BINARY expression.

## Returns

An INTEGER.

The length of string data includes the trailing spaces.
The length of binary data includes trailing binary zeros.

## Examples

```sql
> SELECT len('Spark SQL ');
 10
> SELECT len('床前明月光');
 5
```

## Related functions

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