LENGTH
Description
The LENGTH function is used to calculate the length of a string, returning the number of characters in the string or the number of bytes in a binary string. This function is very useful for processing text data, allowing you to quickly obtain the length information of the text.
Syntax
Parameter Description
expr
: Can be an expression of type string or binary.
Return Result
Returns an integer (int) representing the number of characters in the input string or the number of bytes in the binary string.
Usage Example
- Calculate the length of a regular string:
- Calculate the length of a string containing Chinese characters:
- Calculate the length of a string containing special characters:
Precautions
- The LENGTH function only applies to string and binary types of data, and will return an error for other types of data.