Character strings
A character string is a sequence of bytes. The
length of the string is the number of bytes in the sequence. If the length
is zero, the value is called the empty string. The
empty string should not be confused with the null value.
Fixed-length character strings
All values of a fixed-length character-string column have the same length.
This is determined by the length attribute of the column. The length attribute
must be between 1 through 32766 inclusive.
Varying-length character strings
The types of varying-length character strings are:
- VARCHAR (or synonyms CHAR VARYING and CHARACTER VARYING)
- CLOB (or synonyms CHAR LARGE OBJECT and CHARACTER LARGE OBJECT)
The values of a column with any one of these string types can have different
lengths. The length attribute of the column determines the maximum length
a value can have.
For a VARCHAR column, the length attribute must be between 1 through 32740
inclusive. For a CLOB column, the length attribute must be between 1 through
2 147 483 647 inclusive. For more information about CLOBs, see Large objects.
For the restrictions that apply to the use of long varying-length strings,
see Limitations on use of strings.
Character-string variables
- Fixed-length character-string variables can be used in all host languages
except REXX. (In C, fixed-length character-string variables are limited to
a length of 1.)
- VARCHAR varying-length character-string variables can be used in C, COBOL,
PL/I, REXX, and RPG:
- In PL/I, REXX, and ILE RPG, there is a varying-length character-string
data type.
- In COBOL and C, varying-length character strings are represented as structures.
- In C, varying-length character-string variables can also be represented
by NUL-terminated strings.
- In RPG/400(R), varying-length character-string variables can only be represented
by VARCHAR columns included as a result of an externally described data structure.
- CLOB varying-length character-string variables can be defined in all
host languages except REXX, RPG/400, and COBOL/400(R).
- In ILE RPG, a CLOB varying-length character string is declared using the
SQLTYPE keyword.
- In all other languages, an SQL TYPE IS CLOB clause is used.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.