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
- 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.