The data types
The data types nchar
, nvarchar
and json
are
stored as UTF-8 encoded Unicode (Unicode Version 6.0.0 ISO/IEC 10646:2011).
- The nchar data type specifies fixed-length Unicode data with a maximum length of 16000 characters.
- The nvarchar data type specifies variable-length Unicode data with a maximum length of 16000 characters.
- The JSON data type does not need a specifier and will store json documents as a text of up to 16000 characters.
nchar ( <char-length> ) and nvarchar ( <char-length> )
The <char-length> is the maximum number of Unicode characters that the column can hold as distinct from the number of bytes of storage available for the column data.
Using UTF-8 encoding, each Unicode code point can require 1-4 bytes of storage. So a 10-character string requires 10 bytes of storage if it is ASCII, up to 20 bytes if it is Latin, or as many as 40 bytes if it is pure Kanji (but typically 30 bytes).
nchar and nvarchar with declared character widths of up to 16000 characters are supported. char and varchar can have a maximum character width of 64000 characters.
The system checks for errors that are based on the lengths declared for nchar-class columns just as it does for char columns. If you attempt to insert or load character data longer than the declared column character width, the system displays an error message.