BIT_LENGTH
Description
Returns the length of a string or binary value in bits.
Syntax
BIT_LENGTH( <str>)
Parameters
<str>
The string value for which the length is returned.
Return Value
Returns the number of bits occupied by <str>
in the binary representation, including all 0 and 1.
Examples
-
示例 1
select BIT_LENGTH("abc"), BIT_LENGTH("中国"), BIT_LENGTH(123);
+-------------------+----------------------+-----------------+
| BIT_LENGTH("abc") | BIT_LENGTH("中国") | BIT_LENGTH(123) |
+-------------------+----------------------+-----------------+
| 24 | 48 | 24 |
+-------------------+----------------------+-----------------+ -
NULL 参数
select BIT_LENGTH(NULL);
+------------------+
| BIT_LENGTH(NULL) |
+------------------+
| NULL |
+------------------+