LENGTH function [String]

Function

Returns the number of characters in the specified string.

Syntax

LENGTHstring-expression )

Parameters

string-expression The string.

Example

The following statement returns the value 9:

SELECT LENGTH( 'chocolate' ) FROM iq_dummy

Usage

If the string contains multibyte characters, and the proper collation is being used, LENGTH returns the number of characters, not the number of bytes. If the string is of BINARY data type, the LENGTH function behaves as BYTE_LENGTH.

The LENGTH function is the same as the CHAR_LENGTH function.

Standards and compatibility

See also

“BYTE_LENGTH function [String]”

“CHAR_LENGTH function [String]”

Chapter 11, “International Languages and Character Sets” in the System Administration Guide: Volume 1