BIT_LENGTH
Syntax
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> BIT_LENGTH[BIT_LENGTH]:::quoted
BIT_LENGTH --> End((END))
Purpose
The BIT_LENGTH SQL function gets the number of bits needed to represent a value. For a blob, this is the number of bits for the bytes of the blob. For all other data types, the value is first converted to a text and then the number of bits of the UTF8 representation is determined.
Parameters:
- Value (
ANY): value to determine length in bits for.
Returns: number of bits needed to represent the value as int32.
Examples
BIT_LENGTH retrieves the length in bit of a two-byte blob:
select bit_length(base64_decode('aGk='))
--------
16
BIT_LENGTH retrieves the length in bit of the UTF8 representation of a three-character text:
select bit_length('abc')
--------
24