This is an old revision of the document!



The CHARACTER_LENGTH function returns the number of characters in a string. The abbreviation, CHAR_LENGTH, is supported as a synonym for CHARACTER_LENGTH.

CHARACTER_LENGTH should not be confused with $DATA_LENGTH and $COLUMN_LENGTH. $DATA_LENGTH returns the number of characters plus the null-terminator for C STRING datatypes. $COLUMN_LENGTH returns the length of the column as declared in the table.

This function returns a 4-byte integer.


CHAR[ACTER]_LENGTH ( character_expression )


Required. Any expression that returns a character-class datatype. Examples of expressions are columns, concatenations of columns, literal strings and functions that return a character datatype.


Example 1: Column

> SELECT name, CHARACTER_LENGTH(name) len FROM individuals;
NAME                                                LEN
--------------------------------------------------  -----------
MS. MARY LEWIS                                               14
MRS. ALICE R TOLLIVER                                        21
MR. SIDNEY K TOLLIVER                                        21
MRS. JENNIFER J HOPKINS                                      23
MR. CHARLIE HOPKINS                                          19
MS. KIMBERLY BLUE                                            17
KATHLEEN TUCKER                                              15

Example 2: Character Expression

> SELECT gender, name, CHAR_LENGTH(gender || name) len FROM individuals;
G  NAME                                                LEN
-  --------------------------------------------------  -----------
F  MS. MARY LEWIS                                               15
F  MRS. ALICE R TOLLIVER                                        22
M  MR. SIDNEY K TOLLIVER                                        22
F  MRS. JENNIFER J HOPKINS                                      24
M  MR. CHARLIE HOPKINS                                          20
F  MS. KIMBERLY BLUE                                            18
F  KATHLEEN TUCKER                                              16
Back to top
dev/sql/functions/character_length.1278624613.txt.gz ยท Last modified: 2016/06/28 22:38 (external edit)