Skip to main content

LENGTH

Returns the number of characters in a string input expression prior to the first NULL character, or the number of bytes in a BLOB expression.

See also:
[SELECT]


info

To get the length of a JSON array use the JSON_ARRAY_LENGTH function.

Syntax

SELECT LENGTH(expression) FROM <multipartIdentifier>;

Arguments

expression
An ASCII string or a BLOB.

Returns NULL if expression is NULL.

If expression is numeric then the length of a string representation of expression is returned.

Return Value(s)

Returns an integer.


Examples

Return the length of a string column

SELECT name, length(name) AS len
FROM google.compute.instances
WHERE project = 'stackql-demo'
AND zone = 'australia-southeast1-a';

For more information, see https://www.sqlite.org/lang_corefunc.html#length