Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Wednesday, 21 February 2024

length Function in DB2

In IBM DB2, you can use the LENGTH function to return the number of characters in a string expression. Here's how you can use the LENGTH function with an example:


SELECT LENGTH('Hello World') AS string_length FROM sysibm.sysdummy1;


In this example, 'Hello World' is a string literal. The LENGTH function is applied to this string, and it returns the length of the string, which is 11 characters. sysibm.sysdummy1 is a special one-row table in DB2 used for queries that don't require a real table.


The output of this query would be:

STRING_LENGTH

-------------

           11

This demonstrates how to use the LENGTH function in DB2 to find the length of a string.

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.