O'Reilly logo

Oracle PL/SQL Programming, 4th Edition by Bill Pribyl, Steven Feuerstein

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

Chapter 8. Strings

Variables with character datatypes store text and are manipulated by character functions. Working with character data can range in difficulty from easy to quite challenging. In this chapter, we discuss PL/SQL's core string functionality largely in the context of single-byte character sets—for example, those that are commonly used in Western Europe and the United States. If you are working with Unicode or with multi-byte character sets, or are dealing with multiple languages, be sure to read about globalization and localization issues in Chapter 24.

Tip

CLOB (character large object) and LONG, while arguably character types, cannot be used in the same manner as the character types discussed in this chapter, and are more usefully thought of as large object types. We discuss large object types in Chapter 13.

String Datatypes

Oracle supports four string datatypes, which are summarized in Table 8-1. Which type you should use depends on your answers to the following two questions:

  • Are you working with variable-length or fixed-length strings ?

  • Do you want to use the database character set or the national character set?

Table 8-1. PL/SQL's string datatypes

 

Fixed-length

Variable-length

Database character set

CHAR

VARCHAR2

National character set

NCHAR

NVARCHAR2

You will rarely need or want to use the fixed-length CHAR and NCHAR datatypes in Oracle-based applications; in fact, we recommend that you never use these types unless there is a specific requirement for fixed-length strings. ...

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