BIT_LENGTH
説明
文字列のバイナリ表現の中央値(つまり、バイナリ桁の総数)を返すために使用されます。文字列のバイナリエンコーディングが占めるビット数を計算します。
構文
BIT_LENGTH( <str>)
パラメータ
| parameter | description |
|---|---|
<str> | 計算対象の文字列 |
Return Value
<str>がバイナリ表現で占めるビット数を返します。すべての0と1を含みます。
Examples
select BIT_LENGTH("abc"), BIT_LENGTH("中国"), BIT_LENGTH(123);
+-------------------+----------------------+-----------------------------------------+
| bit_length('abc') | bit_length('中国') | bit_length(cast(123 as VARCHAR(65533))) |
+-------------------+----------------------+-----------------------------------------+
| 24 | 48 | 24 |
+-------------------+----------------------+-----------------------------------------+