LENGTH function
The LENGTH function returns the length of the argument's value as a large integer.
The result is the length of the argument. The length does not include the null indicator byte of column arguments that allow null values. The length of strings includes blanks. The length of a varying-length string is the actual length, not the maximum length.
The length of a graphic string including UTF-16 is the number of double-byte characters.
The length of all other values is the number of bytes used to represent the value:
Data type | Length |
---|---|
SMALLINT | 2 |
INTEGER | 4 |
BIGINT | 8 |
DECIMAL with precision p | The integer part of (p /2) +1 |
DECFLOAT (34) | 16 |
DECFLOAT (16) | 8 |
Single precision floating point | 4 |
Double precision floating point | 8 |
Strings | The length of the string |
DATE | 4 |
TIME | 3 |
TIMESTAMP | 10 |
TIMESTAMP WITH TIMEZONE | 12 |
TIMESTAMP (p) | 7+ (( p +1)/2) |
TIMESTAMP(p) WITH TIMEZONE | 9+(( p +1)/2) |