The NVARCHAR data type

The NVARCHAR data type stores character data in a variable-length field. Data can be a string of single-byte or multibyte letters, digits, and other characters that are supported by the code set of your database locale.

The syntax of the NVARCHAR data type is as follows:

1  %Data type segment(1)  NVARCHAR ( max
2.1!  , 0
2.1  , reserve
1 )
Notes:
  • 1 See HCL OneDB™ Guide to SQL: Syntax.
Element
Description
max
Specifies the maximum number of bytes that can be stored in the column.
reserve
Specifies the minimum number of bytes that can be stored in the column.

You must specify max of the NVARCHAR column. The size of this parameter cannot exceed 255 bytes.

When you place an index on an NVARCHAR column, the maximum size is 254 bytes. You can store shorter, but not longer, character strings than the value that you specify.

Specify the reserve parameter when you initially intend to insert rows with data values having few or no characters in this column but later expect the data to be updated with longer values. This value can range from 0 to 255 bytes but must be less than the max size of the NVARCHAR column. If you do not specify a minimum space value, the default value of reserve is 0.

Although use of NVARCHAR economizes on space that is used in a table, it has no effect on the size of an index. In an index that is based on an NVARCHAR column, each index key has a length equal to max bytes, the maximum size of the column.

The database server does not strip an NVARCHAR object of any user-entered trailing white space, nor does it pad the NVARCHAR object to the full length of the column. However, if you specify a minimum reserved space (reserve), and some of the data values are shorter than that amount, some of the space that is reserved for rows goes unused.