Finding the Length of a String with CHARACTER_LENGTH()

Use the CHARACTER_LENGTH() function to return the number of characters in a string. The CHARACTER_LENGTH() function’s important characteristics are:

  • CHARACTER_LENGTH() returns an integer greater than or equal to zero.

  • CHARACTER_LENGTH() counts characters, not bytes. A multibyte or Unicode character represents one character. (To count bytes, see the Tips in this section.)

  • The length of an empty string is zero.

  • If its argument is null, CHARACTER_LENGTH() returns null. (But see the Oracle exception in the DBMS Tip in this section.)

To find the length of a string:

  • Type:
    CHARACTER_LENGTH(string)
    
    string is a string expression such as a column that contains character strings, a string literal, ...

Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.