Updated on 2026-11-06 GMT+08:00

lengthb

The lengthb function is used to calculate the byte length of a string str.

Similar function: length. The length function returns the length of a string.

Syntax

lengthb(string ) 

Parameters

Parameter

Mandatory

Type

Description

str

Yes

STRING

The input string.

Return Values

Returns a value of type BIGINT.

  • If str is not of type STRING, BIGINT, DOUBLE, DECIMAL, or DATETIME, an error is returned.
  • If str is NULL, NULL is returned.

Example Code

Returns 5.

select lengthb('hello'); 

Returns NULL.

select lengthb(null);