The VARCHAR data type stores variable-length strings. This topic describes the syntax, parameters, and considerations of the VARCHAR data type.
Syntax
VARCHAR(size [BYTE | CHAR])
Parameters
| Parameter | Description |
|---|---|
| size | The length of the stored data in bytes or characters. |
| BYTE | The length of the column in bytes. |
| CHAR | The length of the column in characters. |
Considerations
The maximum size of the VARCHAR2 data type is 32,767 bytes. When you create a VARCHAR column, you must specify the maximum length for the VARCHAR column. Although the actual minimum string allowed for storage in a column of this type is a zero-length string (''), the minimum length must be at least 1 byte. OceanBase Database stores each value in a column in the exact way as specified. If the inserted value exceeds the specified length, an error is returned.
In OceanBase Database, the VARCHAR data type and VARCHAR2 data type are the same, and the VARCHAR2 data type is preferred.