Amazon Redshift
Database Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.


Returns the length of the specified string as the number of bytes.





The input parameter is a CHAR or VARCHAR text string.

Return Type

The OCTET_LENGTH function returns an integer indicating the number of bytes in the input string. The LEN function returns the actual number of characters in multi-byte strings, not the number of bytes. For example, to store three four-byte Chinese characters, you need a VARCHAR(12) column. The LEN function will return 3 for that same string.

Usage Notes

Length calculations do not count trailing spaces for fixed-length character strings but do count them for variable-length strings.


The following example returns the number of bytes and the number of characters in the string français.

select octet_length('français'), len('français'); octet_length | len --------------+----- 9 | 8 (1 row)