LEN
LEN(string);
Section titled “LEN(string);”- string: The input string of which the length is to be determined. The LEN() function will return the number of characters in the string.
Example
Section titled “Example”SELECT LEN('Hello World');Output
Section titled “Output”11Explanation
Section titled “Explanation”The LEN function is used to get the length of a string in SQL. In the given example, the string is ‘Hello World’ which has a length of 11.
LEN( string_expression )
Section titled “LEN( string_expression )”- string_expression: The string expression can be any type of character string for which the length is to be returned. The STRING_EXPRESSION is an expression, typically a column that will be evaluated to a text string. The LEN function then counts the number of characters in that text string.
Example
Section titled “Example”SELECT LEN('Hello, World!');Output
Section titled “Output”12Explanation
Section titled “Explanation”In the example, the LEN() function is used to calculate the length of the string ‘Hello, World!’, which is 12. This count does not include trailing spaces.
LEN(string)
Section titled “LEN(string)”- string: Represents the input string for which the length is calculated. This character input can be of data type CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The length returned is the number of characters in the string. For any NULL input, the return value is NULL.
Example
Section titled “Example”SELECT LEN('Hello World') AS LengthOfString FROM dual;Output
Section titled “Output”10Explanation
Section titled “Explanation”The LEN function in this query returns the length of the string ‘Hello World’, which is 10 characters.