SQL/MX 2.x Reference Manual (G06.24+, H06.03+)

SQL/MX Language Elements
HP NonStop SQL/MX Reference Manual523725-004
6-21
Character String Data Types
CHAR[ACTER] [(length [CHARACTERS])] [char-set] [collate-clause]
[UPSHIFT]
specifies a column with fixed-length character data.
PIC[TURE] X[(length)] [DISPLAY] [char-set] [collate-clause]
[UPSHIFT]
specifies a column with fixed-length character data.
You can specify the number of characters in a PIC X column by specify either
length or multiple Xs, with each X representing one character position. DISPLAY
does not change the meaning of the clause.
PIC is an SQL/MX extension.
CHAR[ACTER] VARYING (length) [CHARACTERS] [char-set]
[collate-clause] [UPSHIFT]
specifies a column with varying-length character data. VARYING specifies that the
number of characters stored in the column can be fewer than the length.
Note that values in a column declared as VARYING can be logically and physically
shorter than the maximum length, but the maximum internal size of a VARYING
column is actually four characters larger than the size required for an equivalent
column that is not VARYING.
VARCHAR (length) [char-set] [collate-clause] [UPSHIFT]
specifies a column with varying-length character data.
VARCHAR is equivalent to data type CHAR[ACTER] VARYING.
NCHAR [(length)] [collate-clause] [UPSHIFT]
NATIONAL CHAR[ACTER] [(length)] [collate-clause]
[UPSHIFT]
specifies a column with data in the pre-defined national character set.
NCHAR VARYING [(length)] [collate-clause] [UPSHIFT]
NATIONAL CHAR[ACTER] VARYING (length) [collate-clause]
[UPSHIFT]
specifies a column with varying-length data in the pre-defined national character
set.
Considerations for Character String Data Types
Difference Between CHAR and VARCHAR
You can specify a fixed-length character column as CHAR(n), where n is the number of
characters you want to store. However, if you store five characters into a column
specified as CHAR(10), ten characters are stored where the rightmost five characters
are blank.