Reference Manual
CHAPTER 7. SQL Data Types
For storing strings of letters, numbers and symbols.
Adaptive Server Anywhere treats CHAR, VARCHAR, and LONG VARCHAR columns all as the same type. Values up to 254 characters are stored as short strings, with a preceding length byte. Any values that are longer than 255 bytes are considered long strings. Characters after the 255th are stored separate from the row containing the long string value.
There are several functions (see SQL Functions) that will ignore the part of any string past the 255th character. They are soundex, similar, and all of the date functions. Also, any arithmetic involving the conversion of a long string to a number will work on only the first 255 characters. It would be extremely unusual to run in to one of these limitations.
All other functions and all other operators work with the full length of long strings.
Character data is placed in the database using the exact binary representation that is passed from the application. This usually means that character data is stored in the database with the binary representation of the current code page. The code page is the character set representation used by IBM-compatible personal computers. You can find documentation about code pages in the documentation for your operating system.
Most code pages are the same for the first 128 characters. If you use special characters from the top half of the code page (accented international language characters), you must be careful with your databases. In particular, if you copy the database to a machine that uses a different code page, those special characters will be retrieved from the database using the original code page representation. With the new code page, they will appear on the screen to be the wrong characters.
This problem also appears if you have two clients using the same multi-user server, but run with different code pages. Data inserted or updated by one client may appear incorrect to the other.
This problem also shows up if a database is used across platforms. PowerBuilder and many other Windows applications insert data into the database in the standard ANSI character set. If non-Windows applications attempt to use this data, they will not properly display or update the extended characters.
This problem is quite complex. If any of your applications use the extended characters in the upper half of the code page, make sure that all clients and all machines using the database use the same or a compatible code page.
Data type lengths and precision of less than one are not allowed.
The CHARACTER (n) alternative for CHAR is not supported in Adaptive Server Enterprise.
Adaptive Server Anywhere does not support the NCHAR and NVARCHAR data types provided by Adaptive Server Enterprise.
Character data of maximum length max-length bytes.
{ CHAR | CHARACTER } [ ( max-length ) ]
The default value of max-length is 1.
For strings up to 254 bytes in length, the storage requirement is the number of bytes in the string plus one additional byte. For longer strings, there is more overhead.
Strings of multi-byte characters can be held as the CHAR data type, but max-length is in bytes, not characters.
max-length The maximum length in bytes of the string. The maximum size allowed is 32,767.
SQL/92 Compatible with SQL/92.
Sybase Compatible with Adaptive Server Enterprise. In Adaptive Server Enterprise, the storage requirements for CHAR data types is always max-length. The maximum max-length for ASE is 255.
Other database systems In many other database management systems, unlike Adaptive Server Anywhere,CHAR data types require max-length bytes of storage, regardless of the length of the actual string.
Same as CHAR.
{ VARCHAR | CHARACTER VARYING } [ ( max-length ) ]
The default value of max-length is 1.
For strings up to 254 bytes in length, the storage requirements are the number of bytes in the string plus one additional byte. For longer strings, there is more overhead.
Strings of multi-byte characters can be held as the CHAR data type, but it is important to note that max-length is in bytes, not characters.
max-length The maximum length of the string, in bytes. The maximum size allowed is 32,767.
SQL/92 Compatible with SQL/92.
Sybase Compatible with Adaptive Server Enterprise. The maximum max-length for Adaptive Server Enterprise is 255.
Arbitrary length character data.
LONG VARCHAR
Arbitrary length strings. The maximum size is limited by the maximum size of the database file (currently 2 gigabytes).
In addition to the length of the string itself, there is some additional overhead for storage.
SQL/92 Vendor extension.
Sybase Not supported in Adaptive Server Enterprise.
This is a user-defined data type. It is implemented as a LONG VARCHAR allowing NULL.
TEXT
Arbitrary length strings. The usage is as for LONG VARCHAR.
SQL/92 Vendor extension.
Sybase Compatible with Adaptive Server Enterprise.