Sqlite Length Function

SQLite: length Function

This SQLite post explains how to use the SQLite length function with syntax and examples.

Description

The SQLite length function returns the length of the specified string (measured in characters).

Syntax

The syntax for the length function in SQLite is:

length( string )

Parameters or Arguments

string

The string to return the length for.

Note

  • If a numeric value is passed into the length function, it will be converted to a string and then the length will be calculated.

Applies To

The length function can be used in the following versions of SQLite:

  • SQLite 3.8.6, SQLite 3.8.x, SQLite 3.7.x, SQLite 3.6.x

Example

Let's look at some SQLite length function examples and explore how to use the length function in SQLite.

For example:

sqlite> SELECT length('AODBA.com');
Output:   9

sqlite> SELECT length('dbd');
Output:   3

sqlite> SELECT length(32);
Output:   2

sqlite> SELECT length(NULL);
Output:   NULL

sqlite> SELECT length('');
Output:   0

sqlite> SELECT length(' ');
Output:   1