CHARACTER_LENGTH is a scalar string function defined in the SQL standard that counts the number of characters in a string, not bytes. It works on CHAR, VARCHAR, TEXT and similar data types. The function ignores multibyte‐encoding details, so a 3-byte UTF-8 character counts as 1. On fixed-length CHAR columns, trailing spaces are usually included in the count unless the DBMS automatically pads or trims them. CHARACTER_LENGTH is synonymous with CHAR_LENGTH in many systems, and with LENGTH in some dialects, but the standard form is CHARACTER_LENGTH. The return type is an integer representing character count. The function is deterministic, inexpensive, and can be indexed in predicates.
string_expression
(string) - Any character or text expression whose length you want to measureSQL-92
In many databases they are synonyms, but some dialects use LENGTH to count bytes. CHARACTER_LENGTH is standard and always counts characters.
Yes. It returns the number of characters, not bytes, so multibyte characters count as 1 each.
If the input expression is NULL, the result is NULL.
Use TRIM(column) inside CHARACTER_LENGTH, e.g., CHARACTER_LENGTH(TRIM(my_char_col)).