CHARACTER_LENGTH returns an INTEGER value representing the number of characters in a string. It strips the padding from CHAR expressions but not from VARCHAR expressions.
Syntax
[ CHAR_LENGTH | CHARACTER_LENGTH ] ( expression )
Semantics
expression |
(CHAR or VARCHAR) is the string to measure |
Notes
Examples
> SELECT CHAR_LENGTH('1234 '::CHAR(10));
char_length
-------------
4
(1 row)
> SELECT CHAR_LENGTH('1234 '::VARCHAR(10));
char_length
-------------
6
(1 row)
> SELECT CHAR_LENGTH(NULL::CHAR(10)) IS NULL;
?column?
----------
t
(1 row)