This topic introduces the general-purpose character types available in POLARDB compatible with Oracle.
|CHAR[(n)]||Fixed-length character string, blank-padded to the size specified by n|
|CLOB||Large variable-length up to 1 GB|
|LONG||Variable unlimited length.|
|NVARCHAR(n)||Variable-length national character string, with limit.|
|NVARCHAR2(n)||Variable-length national character string, with limit.|
|STRING||Alias for VARCHAR2.|
|VARCHAR(n)||Variable-length character string, with limit (considered deprecated, but supported for compatibility)|
|VARCHAR2(n)||Variable-length character string, with limit|
If you do not specify a value for n, the default value will be 1. If the string to be assigned is shorter than n, values of the CHAR type will be space-padded to the specified width (n), and will be stored and displayed that way.
Padding spaces are semantically insignificant. That is, trailing spaces are disregarded when comparing two values of type CHAR, and the spaces will be removed when a CHAR value is converted to one of the other string types.
If you explicitly cast an over-length value to a CHAR(n) type, the value will be truncated to n characters without raising an error as specified by the SQL standard.
VARCHAR, VARCHAR2, NVARCHAR, and NVARCHAR2
If the string to be assigned is shorter than n, values of type VARCHAR, VARCHAR2, NVARCHAR, and NVARCHAR2 will store the shorter string without padding.
If you explicitly cast a value to a VARCHAR type, an over-length value will be truncated to n characters without raising an error as specified by the SQL standard.
The storage requirement for data of these types is the actual string plus 1 byte if the string is less than 127 bytes, or 4 bytes if the string is 127 bytes or greater. In the case of CHAR, the padding also requires storage. Long strings are compressed by the system automatically, so the physical requirement on disk may be less. Long values are stored in background tables so they do not interfere with rapid access to the shorter column values.
The database character set determines the character set used to store textual values.