Home

CHARLENGTH

CHARLENGTH is a function used in SQL and related database systems to determine the number of characters in a string. In the SQL standard, the function is called CHARACTER_LENGTH, and CHAR_LENGTH is commonly provided as an alias. The result represents the count of user-perceived characters, not the underlying storage size in bytes.

Behavior and compatibility vary by database. In many systems, CHAR_LENGTH and CHARACTER_LENGTH are interchangeable and return

NULL handling also follows common SQL rules: if the input is NULL, the result is NULL. The

Unicode and multibyte considerations are important. When strings use multibyte encodings (such as UTF-8), CHAR_LENGTH counts

Examples:

- SELECT CHAR_LENGTH('Hello') returns 5.

- SELECT CHAR_LENGTH('こんにちは') returns 5 in systems that count by characters (not bytes).

See also: LENGTH, OCTET_LENGTH, CHARACTER_LENGTH, char_length, byte length functions.

the
number
of
characters
in
the
input.
Some
databases
distinguish
between
character
length
and
byte
length;
for
example,
a
string
in
a
multibyte
character
set
may
occupy
more
than
one
byte
per
character.
In
such
cases,
a
separate
function
often
exists
to
report
the
byte
length.
Because
of
this,
CHAR_LENGTH
is
most
reliable
when
the
database
adheres
to
the
standard
aliasing
between
character
length
functions.
exact
behavior
can
vary
if
the
database
applies
specific
null
semantics,
but
the
typical
outcome
is
a
NULL
result.
characters,
not
bytes,
which
can
differ
from
a
byte-length
function.