PostgreSQL length() Function

The PostgreSQL length() function returns the length of the specified string, that is, the number of characters.

length() Syntax

This is the syntax of the PostgreSQL length() function:

length(str)

Parameters

str

Required. The string whose length to return.

Return value

The PostgreSQL length() function returns the number of characters in a string str .

If the parameter is NULL, the function will return NULL.

length() Examples

This example shows how to use the length() function to return the length of a string.

SELECT length('hello world') AS "length('hello world')";
 length('hello world')
-----------------------
                    11