Contents IndexChapter 41.  SQL Anywhere Data Types Numeric data types

User's Guide
   Part VI. SQL Anywhere Reference
     Chapter 41. SQL Anywhere Data Types
      Character data types

Purpose

For storing strings of letters, numbers and symbols.

Syntax

     Character data types:
          CHAR[ ( max-length ) ]
          | CHARACTER [ ( max-length ) ]
          | CHARACTER VARYING [ ( max-length ) ]
          | LONG VARCHAR
          | VARCHAR [ ( max-length ) ]

Description

CHAR [(max-length)] Character data of maximum length max-length bytes. If max-length is omitted, the default is 1. The maximum size allowed is 32,767.

  See the notes below on character data representation in the database, and on storage of long strings.

CHARACTER [(max-length)] Same as CHAR[(max-length)].

CHARACTER VARYING[(max-length)] Same as CHAR[(max-length)].

LONG VARCHAR Arbitrary length character data. The maximum size is limited by the maximum size of the database file (currently 2 gigabytes).

VARCHAR [(max-length)] Same as CHAR[(max-length)].

Notes

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.

All 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 different machine using 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 multiuser server, but running with different code pages. Data inserted or updated by one client may appear incorrect to another.

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.

Long strings

SQL Anywhere treats CHAR, VARCHAR, and LONG VARCHAR columns all as the same type. Values up to 254 characters are stored as short strings, which are stored 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 "Watcom-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 will work with the full length of long strings.

Contents IndexChapter 41.  SQL Anywhere Data Types Numeric data types