December 16th, 2008

OCTET_LENGTH (bit length / 8)

The OCTET_LENGTH function returns the number of octets (8 bits) within the string expression.
Format: OCTET_LENGTH(string)

Example:           SELECT CUST_NAME,
                          OCTET_LENGTH(CUST_NAME) AS 'OCTET_LENGTH'
                     FROM CUSTOMER_TBL;

Result:

                   

> The length of an empty string (‘ ‘) is zero.
> Access, DB2, MySQL, Oracle, PostgreSQL, and SQL Server do not support OCTET_LENGTH.
> Access uses LEN(string) to find the number of characters.
> DB2 and Oracle use LENGTH(string) to find the number of characters.
> SQL Server uses DATALENGTH(string) to find the number of characters.
> MySQL uses BIT_COUNT(string) to find the number of bits.
> Oracle uses LENGTHB(string) to find the number of bits.

Comments are closed.

Sorry, the comment form is closed at this time.