Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

BIT_LENGTH Function

Description

The BIT_LENGTH function returns the length (bits) of a character string or bit string as an integer value. The return value of the BIT_LENGTH function may differ depending on the character set, because for the character string, the number of bytes taken up by a single character is different depending on the character set of the data input environment (e.g., EUC-KR: 2*8 bits). For details about character sets supported by CUBRID, see Definition and Characteristics.

Syntax

BIT_LENGTH ( string )

 

string :

? bit string

? character string

? NULL

  • string : Specifies the character string or bit string whose number of bits is to be calculated. If this value is NULL, NULL is returned.
Example

SELECT BIT_LENGTH('');

=================

                0

 

SELECT BIT_LENGTH('CUBRID');

=======================

                     48

 

SELECT BIT_LENGTH('큐브리드');

=========================

                       64

 

SELECT BIT_LENGTH(B'010101010');

===========================

                          9

 

CREATE TABLE bit_length_tbl (char_1 CHAR, char_2 CHAR(5), varchar_1 VARCHAR, bit_var_1 BIT VARYING);

INSERT INTO bit_length_tbl VALUES('', '', '', B''); --Length of empty string

INSERT INTO bit_length_tbl VALUES('a', 'a', 'a', B'010101010'); --English character

INSERT INTO bit_length_tbl VALUES(NULL, '큐', '큐', B'010101010'); --Korean character and NULL

INSERT INTO bit_length_tbl VALUES(' ', ' 큐', ' 큐', B'010101010'); --Korean character and space

 

SELECT BIT_LENGTH(char_1), BIT_LENGTH(char_2), BIT_LENGTH(varchar_1), BIT_LENGTH(bit_var_1) FROM bit_length_tbl;

 

=== <Result of SELECT Command in Line 15> ===

 

================================================================================

8                   40                       0                       0

8                   40                       8                       9

NULL                40                      16                       9

8                   40                      24                       9