LENGTH
LENGTH(str)
Section titled “LENGTH(str)”- str: The string argument for which the length is to be returned. The function LENGTH(str) returns the length of the string str in bytes.
Example
Section titled “Example”SELECT LENGTH('SQL Documentation') AS String_Length;Output
Section titled “Output”+----------------+| String_Length |+----------------+| 17|+----------------+Explanation
Section titled “Explanation”The LENGTH function in MySQL is used to retrieve the length of a string. In this example, it is applied to the string ‘SQL Documentation’, returning 17, which represents the number of characters (including spaces) in this string.
LENGTH(string text) RETURNS integer
Section titled “LENGTH(string text) RETURNS integer”- string text: This is the text string that you want to measure the length of. It is made up of any sequence of characters.
- returns integer: This indicates the type of output returned by the LENGTH function. It returns the integer value representing the number of characters in the specified string text.
Example
Section titled “Example”SELECT LENGTH('PostgreSQL');Output
Section titled “Output”11Explanation
Section titled “Explanation”The LENGTH function returns the number of characters in the string ‘PostgreSQL’, which is 11.
LENGTH( string )
Section titled “LENGTH( string )”- string: This refers to the string for which length is to be calculated. LENGTH function returns the number of characters in the string.
Example
Section titled “Example”SELECT LENGTH('SQL Server') AS String_Length;Output
Section titled “Output”String_Length-------------11Explanation
Section titled “Explanation”The LENGTH function in SQL Server returns the number of characters in the provided string. In the given example, the string ‘SQL Server’ consists of 11 characters, including the space, so the output is 11.
LENGTH(string)
Section titled “LENGTH(string)”- string: This is the input parameter to the LENGTH function. The string parameter is the character string from which LENGTH function will count the number of characters. If the input string is of CHAR data type, it trims trailing blanks. For null input, the LENGTH function returns null.
Example
Section titled “Example”SELECT LENGTH('Hello, World!') AS String_Length FROM dual;Output
Section titled “Output”STRING_LENGTH-------------13Explanation
Section titled “Explanation”The LENGTH function in Oracle SQL returns the length of the provided string, in this case ‘Hello, World!’, which is 13. The LENGTH function counts the number of characters in the input string, including punctuation and spaces.
LENGTH(X)
Section titled “LENGTH(X)”- x: The string value whose length is to be determined. LENGTH(X) function returns the length of the string X.
Example
Section titled “Example”SELECT LENGTH('SQL Documentation');Output
Section titled “Output”16Explanation
Section titled “Explanation”The LENGTH function in SQLite is used to determine the length of a specified string. In this case, the string ‘SQL Documentation’ has a length of 16. The space between the words is included in this count.