The VARCHAR data type is used to store variable-length strings. This topic describes the syntax, parameters, and usage of the VARCHAR data type.
Syntax
VARCHAR(size [BYTE | CHAR])
Parameters
| Parameter | Description |
|---|---|
| size | The length of the stored bytes or characters. |
| BYTE | The length of the column in bytes. |
| CHAR | The length of the column in characters. |
Considerations
The maximum length of the VARCHAR2 data type is 32767. When creating a column of the VARCHAR data type, you must specify the maximum length for the VARCHAR column. Although you can store an empty string (``) as the actual string, the maximum length must be at least 1 byte. OceanBase Database stores each value exactly as specified in the column. If you insert a value that exceeds the specified length, an error is returned.
In OceanBase Database, the VARCHAR data type is the same as the VARCHAR2 data type. Generally, VARCHAR2 is used.
