CHAR_LENGTH
Returns the number of characters in a string.
PostgreSQL 17.5
CHAR_LENGTH(string)Parameters
- stringtext
- Source string
Return value
An integer, the number of characters, not bytes
Examples
Characters and bytes in a Cyrillic string
PostgreSQL 17.5
SELECT CHAR_LENGTH('привет') AS char_length,
OCTET_LENGTH('привет') AS byte_length;Names longer than 13 characters
PostgreSQL 17.5
SELECT member_name,
CHAR_LENGTH(member_name) AS name_length
FROM FamilyMembers
WHERE CHAR_LENGTH(member_name) > 13;Details
It is a synonym for LENGTH: unlike in MySQL, where LENGTH counts bytes, both functions count characters. The size of a string in bytes is returned by OCTET_LENGTH.