length()

Scalar. Returns the number of bytes of a given binary value, string, or multibyte string.

Syntax

length ( expression )

Parameters

expression

A binary value, string, or multibyte string.

Usage

Returns the number of bytes that make up a given value. The function can take a binary value, string, or multibyte string as its argument, and it returns an integer. If the argument is NULL, the function returns NULL.
Note: To make the function return the number of characters in multibyte strings, enable the utf8 project configuration option. For more information on how to configure the utf8 option, see the Studio Users Guide and the Configuration and Administration Guide.

Example

length (hex_binary ('0xaa1234')) returns 3.

length (hex_binary ('aa')) returns 1.

length ('ABCDE') returns 5.

length ('Multibyte String Example') returns 6 (with utf8 disabled) or 2 (with utf8 enabled).