# LENGTH

Returns the byte length of a given string, array, or binary object.

## Syntax

```sql
LENGTH (expr)

```

## Arguments

* expr: any string, [array](https://docs.singlestore.com/db/v9.1/reference/sql-reference/procedural-sql-reference/array.md), or binary object

## Return Type

Integer

## Examples

## Example 1

```sql
SELECT CHARACTER_LENGTH('olé'), LENGTH('olé');

```

```output

+--------------------------+----------------+
| CHARACTER_LENGTH('olé')  | LENGTH('olé')  |
+--------------------------+----------------+
|                        3 |              4 |
+--------------------------+----------------+

```

The [CHARACTER\_LENGTH](https://docs.singlestore.com/db/v9.1/reference/sql-reference/string-functions/character-length.md) function returns the number of characters in the string, while the LENGTH() function returns the number of bytes in the string.

## Example 2

```sql
DELIMITER //
CREATE OR REPLACE FUNCTION get_length() RETURNS INT AS
  DECLARE
    a ARRAY(VARCHAR(30));
  BEGIN
    a = ['SAM','JOE','TRUDY'];
    RETURN LENGTH(a);
  END //
DELIMITER ;

SELECT get_length() AS "LENGTH";

```

```output

+--------+
| LENGTH |
+--------+
|      3 |
+--------+

```

***

Modified at: February 27, 2023

Source: [/db/v9.1/reference/sql-reference/string-functions/length/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/string-functions/length/)

(An index of the documentation is available at /llms.txt)
