The maximum length of the string. This default value is 1.
If byte-length semantics are used (CHAR or CHARACTER is not specified as part of the length), then the length is in bytes, and the length must be in the range of 1 to 32767.
If character-length semantics are used (CHAR or CHARACTER is specified as part of the length), then the length is in characters,
and you must specify max-length. max-length can be a maximum of 32767 characters.
Multibyte characters can be stored as VARCHAR, but the declared length refers to bytes, not characters.
VARCHAR can also be specified as CHAR VARYING or CHARACTER VARYING. Regardless of which syntax is used, the data type is described
VARCHAR is semantically equivalent to CHAR, although they are different types. In SQL Anywhere, VARCHAR is a variable-length
type. In other relational database management systems, VARCHAR is a fixed-length type, and data is padded with blanks to max-length bytes of storage. SQL Anywhere does not blank-pad stored character data.
How VARCHAR columns are described depends on the client interface, the character sets used, and if character-length semantics
are used. For example, in embedded SQL the described length is the maximum number of bytes in the client character set. If
the described length would be more than 32767 bytes, the column is described as type DT_LONGVARCHAR. The following table shows
some embedded SQL examples and the results returned when a DESCRIBE is performed:
Compatible with SQL/2008. In the standard, character-length semantics are the default, whereas in SQL Anywhere byte-length
semantics are the default. There are minor inconsistencies with the SQL standard due to case-insensitive collation support
and SQL Anywhere blank-padding support.
The SQL/2008 standard supports explicit character- or byte-length semantics as SQL language feature T061.