Skip to main content

Categories: Binary

BIT_LENGTH

Returns 8 times the byte length of the input string. Multi-byte characters count as multiple bytes. Returns NULL if the input is NULL.

Syntax​

BIT_LENGTH(expression varchar) → integer​

  • expression: String expression.

Examples

BIT_LENGTH example
SELECT BIT_LENGTH('DREMIO')
-- 48
BIT_LENGTH example
SELECT BIT_LENGTH('abc')
-- 24
Calculate the bit length of a string with a multi-byte character
SELECT BIT_LENGTH('ñ')
-- 16
BIT_LENGTH example
SELECT BIT_LENGTH(NULL)
-- null