Neoview SQL Reference Manual (R2.4)
CHAR[ACTER] VARYING (length) [CHARACTERS] [char-set] [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 bytes larger than the size required for an equivalent column that is not VARYING.
VARCHAR (length) [char-set] [UPSHIFT]
specifies a column with varying-length character data.
VARCHAR is equivalent to data type CHAR[ACTER] VARYING.
NCHAR [(length)] [UPSHIFT]NATIONAL CHAR[ACTER] [(length)] [UPSHIFT]
specifies a column with data in the pre-defined national character set.
NCHAR VARYING [(length)] [UPSHIFT]NATIONAL CHAR[ACTER] VARYING (length)
[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.
If you do not want to have blanks added to your character string, you can specify a variable-length
character column as VARCHAR(n), where n is the maximum number of characters you want to
store. If you store five characters in a column specified as VARCHAR(10), only the five characters
are stored logically—without blank padding.
Maximum Byte Length of a Character Column
Maximum Length in TableData Type
32708
1
Fixed-length
32708
1
*Variable-length
1 The maximum row size is 32708 bytes, but the actual row size is less than that because of bytes used by the header,
null indicator, column length indicator, and other columns in the table.
Collations
A collation contains rules for a collating sequence (the sequence in which characters are ordered
for sorting), case, and character class and character string equivalence. To be compared, character
strings must be from the same character set. When two strings are compared, the comparison is
made with a temporary copy of the shorter string that has been padded on the right with blanks
to have the same length as the longer string.
In Neoview SQL, a character data type can be associated only with the DEFAULT collation,
which compares the binary code values of characters in a character string. When comparing two
equal length strings, s1 and s2, Neoview SQL compares the binary code values of the
corresponding characters of s1 and s2 until it finds a difference. If Neoview SQL finds a difference
and the differing character value of s1 is less than that of s2, s1 is considered to come before
s2. If the differing character value of s2 is less than that of s1, s2 is considered to come before
s1. If there is no difference, s2 is considered equal to s2.
NCHAR Columns in SQL Tables
234 SQL Language Elements