O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required