BIT_LENGTH
Returns the length of a string in bits.
MySQL 8.1
BIT_LENGTH(str)Parameters
- strVARCHAR
- String to measure
Return value
An integer, the length in bits; NULL for NULL
Examples
Latin and Cyrillic
MySQL 8.1
SELECT BIT_LENGTH('abc') AS latin,
BIT_LENGTH('абв') AS cyrillic;Bits and bytes of names
MySQL 8.1
SELECT good_name,
BIT_LENGTH(good_name) AS bits,
OCTET_LENGTH(good_name) * 8 AS bytes_times_8
FROM Goods
LIMIT 3;Details
The result is always 8 times OCTET_LENGTH: in utf8mb4 a Latin letter takes 8 bits, and a Cyrillic letter takes 16.